Repository navigation
feat: detect not-found via error in bool, null and geo index open - #9265
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughThis PR changes multiple read-only index open functions to return OperationResult<Option> and to treat missing on-disk sentinel directories/files as Ok(None). Implementations use OkNotFound/.ok_not_found() when opening underlying storage, return Ok(None) when the sentinel is absent, return Err for inconsistent partial storage, and wrap successful constructions in Ok(Some(...)). Tests were updated to unwrap the extra Option layer and new tests assert inconsistent-storage errors. Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/segment/src/common/flags/read_only_roaring_flags.rs (1)
76-87: 💤 Low valueConsider handling missing flags file the same as missing status file.
If the status file exists (line 56-70 succeeds) but the flags file is missing,
StoredBitSlice::openwill return an error rather thanOk(None). This creates an asymmetry: a directory with only the status file causes an error, while a completely missing directory returnsOk(None).If this partial state can occur (e.g., due to interrupted writes or partial cleanup), consider wrapping the flags file open with
.ok_not_found()?as well for consistency. If the invariant is that both files always exist together, the current behavior is fine but could benefit from a comment clarifying this assumption.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/segment/src/common/flags/read_only_roaring_flags.rs` around lines 76 - 87, The code calls StoredBitSlice::<S>::open for FLAGS_FILE and will error if the flags file is missing, causing asymmetry with the status file handling; update the flags open to mirror the status handling by wrapping the StoredBitSlice::open call for flags_path with .ok_not_found()? so a missing flags file returns Ok(None) instead of an error (or, if you intend files to always co-exist, add a clarifying comment near FLAGS_FILE/flags_path and StoredBitSlice::open to document that invariant). Ensure you reference StoredBitSlice::open, flags_path and FLAGS_FILE when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@lib/segment/src/common/flags/read_only_roaring_flags.rs`:
- Around line 76-87: The code calls StoredBitSlice::<S>::open for FLAGS_FILE and
will error if the flags file is missing, causing asymmetry with the status file
handling; update the flags open to mirror the status handling by wrapping the
StoredBitSlice::open call for flags_path with .ok_not_found()? so a missing
flags file returns Ok(None) instead of an error (or, if you intend files to
always co-exist, add a clarifying comment near FLAGS_FILE/flags_path and
StoredBitSlice::open to document that invariant). Ensure you reference
StoredBitSlice::open, flags_path and FLAGS_FILE when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 704c052d-513b-4e80-9133-8de252897e54
📒 Files selected for processing (9)
lib/segment/src/common/flags/read_only_roaring_flags.rslib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rslib/segment/src/index/field_index/bool_index/read_only_bool_index/mod.rslib/segment/src/index/field_index/geo_index/mutable_geo_index/read_only/lifecycle.rslib/segment/src/index/field_index/geo_index/mutable_geo_index/read_only/mod.rslib/segment/src/index/field_index/geo_index/read_only/lifecycle.rslib/segment/src/index/field_index/geo_index/read_only/mod.rslib/segment/src/index/field_index/null_index/read_only_null_index/lifecycle.rslib/segment/src/index/field_index/null_index/read_only_null_index/mod.rs
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/segment/src/index/field_index/null_index/read_only_null_index/lifecycle.rs (1)
32-44:⚠️ Potential issue | 🟠 Major | ⚡ Quick winCheck for
is_null-only leftovers before returningOk(None).This has the same one-sided inconsistency detection as the bool opener: when
has_valuesis missing, the function returnsOk(None)without checking whetheris_nullis still on disk. That means anis_null-only partial index is silently treated as absent instead of corrupt. Please branch on both opens together so only(None, None)maps toOk(None).Suggested shape
- let Some(has_values_flags) = - ReadOnlyRoaringFlags::open(fs, &path.join(HAS_VALUES_DIRNAME))? - else { - // Files don't exist, cannot load - return Ok(None); - }; - // `has_values` exists, so `is_null` must too — a missing `is_null` is - // inconsistent storage, not a missing index. - let Some(is_null_flags) = ReadOnlyRoaringFlags::open(fs, &path.join(IS_NULL_DIRNAME))? - else { - return Err(OperationError::service_error(format!( - "inconsistent null index at {path:?}: {HAS_VALUES_DIRNAME} exists but {IS_NULL_DIRNAME} is missing" - ))); - }; + let has_values_flags = ReadOnlyRoaringFlags::open(fs, &path.join(HAS_VALUES_DIRNAME))?; + let is_null_flags = ReadOnlyRoaringFlags::open(fs, &path.join(IS_NULL_DIRNAME))?; + + let (has_values_flags, is_null_flags) = match (has_values_flags, is_null_flags) { + (None, None) => return Ok(None), + (Some(has_values_flags), Some(is_null_flags)) => (has_values_flags, is_null_flags), + (Some(_), None) => { + return Err(OperationError::service_error(format!( + "inconsistent null index at {path:?}: {HAS_VALUES_DIRNAME} exists but {IS_NULL_DIRNAME} is missing" + ))); + } + (None, Some(_)) => { + return Err(OperationError::service_error(format!( + "inconsistent null index at {path:?}: {IS_NULL_DIRNAME} exists but {HAS_VALUES_DIRNAME} is missing" + ))); + } + };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/segment/src/index/field_index/null_index/read_only_null_index/lifecycle.rs` around lines 32 - 44, Change the one-sided existence check so both flags are attempted before deciding absence: call ReadOnlyRoaringFlags::open for both HAS_VALUES_DIRNAME and IS_NULL_DIRNAME (using the same fs and path) and then match on the pair so only (None, None) returns Ok(None); any case where one exists and the other is None should return an OperationError::service_error with a message mentioning the inconsistent null index (use HAS_VALUES_DIRNAME and IS_NULL_DIRNAME in the message) and successful opens should bind to has_values_flags and is_null_flags for subsequent use.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@lib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rs`:
- Around line 28-38: Open both flag directories using ReadOnlyRoaringFlags::open
for path.join(TRUES_DIRNAME) and path.join(FALSES_DIRNAME) before returning,
then branch on the pair: if both are None return Ok(None); if exactly one is
Some and the other None return Err(OperationError::service_error(...))
describing the inconsistent bool index and which side is missing (e.g.,
"{TRUES_DIRNAME} exists but {FALSES_DIRNAME} is missing" or vice versa); only
proceed when both trues_flags and falses_flags are Some. Use the existing path,
TRUES_DIRNAME, FALSES_DIRNAME, ReadOnlyRoaringFlags::open, and
OperationError::service_error symbols to locate and implement the change.
---
Outside diff comments:
In
`@lib/segment/src/index/field_index/null_index/read_only_null_index/lifecycle.rs`:
- Around line 32-44: Change the one-sided existence check so both flags are
attempted before deciding absence: call ReadOnlyRoaringFlags::open for both
HAS_VALUES_DIRNAME and IS_NULL_DIRNAME (using the same fs and path) and then
match on the pair so only (None, None) returns Ok(None); any case where one
exists and the other is None should return an OperationError::service_error with
a message mentioning the inconsistent null index (use HAS_VALUES_DIRNAME and
IS_NULL_DIRNAME in the message) and successful opens should bind to
has_values_flags and is_null_flags for subsequent use.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: cb607a35-907e-4ba9-bbd1-f55806c051c0
📒 Files selected for processing (4)
lib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rslib/segment/src/index/field_index/bool_index/read_only_bool_index/mod.rslib/segment/src/index/field_index/null_index/read_only_null_index/lifecycle.rslib/segment/src/index/field_index/null_index/read_only_null_index/mod.rs
1d64c14 to
11683ef
Compare
11683ef to
9a97cf7
Compare
All Submissions:
devbranch (notmaster) and my branch was created fromdev.New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --workspace --all-featurescommand?Changes to Core Features: