Skip to content

feat: detect not-found via error in bool, null and geo index open - #9265

Merged
coszio merged 3 commits into
devfrom
feat/readonly-bool-null-geo-not-found
Jun 2, 2026
Merged

coszio merged 3 commits into
devfrom
feat/readonly-bool-null-geo-not-found

Conversation

@dancixx

@dancixx dancixx commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

All Submissions:

⚠️ PRs must target the dev branch. If your PR targets master, please change the base branch to dev before requesting a review.

  • My PR targets the dev branch (not master) and my branch was created from dev.
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --workspace --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: a5a92ee5-172e-4575-bf92-bdfe61583cd7

📥 Commits

Reviewing files that changed from the base of the PR and between 11683ef and d24dbbd.

📒 Files selected for processing (9)
  • lib/segment/src/common/flags/read_only_roaring_flags.rs
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rs
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/mod.rs
  • lib/segment/src/index/field_index/geo_index/mutable_geo_index/read_only/lifecycle.rs
  • lib/segment/src/index/field_index/geo_index/mutable_geo_index/read_only/mod.rs
  • lib/segment/src/index/field_index/geo_index/read_only/lifecycle.rs
  • lib/segment/src/index/field_index/geo_index/read_only/mod.rs
  • lib/segment/src/index/field_index/null_index/read_only_null_index/lifecycle.rs
  • lib/segment/src/index/field_index/null_index/read_only_null_index/mod.rs
🚧 Files skipped from review as they are similar to previous changes (9)
  • lib/segment/src/index/field_index/geo_index/read_only/mod.rs
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/mod.rs
  • lib/segment/src/index/field_index/geo_index/read_only/lifecycle.rs
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rs
  • lib/segment/src/index/field_index/null_index/read_only_null_index/mod.rs
  • lib/segment/src/index/field_index/geo_index/mutable_geo_index/read_only/mod.rs
  • lib/segment/src/common/flags/read_only_roaring_flags.rs
  • lib/segment/src/index/field_index/null_index/read_only_null_index/lifecycle.rs
  • lib/segment/src/index/field_index/geo_index/mutable_geo_index/read_only/lifecycle.rs

📝 Walkthrough

Walkthrough

This 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

  • qdrant/qdrant#9200: Related changes to ReadOnlyBoolIndex::open and read-only boolean index behavior.
  • qdrant/qdrant#9211: Related read-only geo index opening adjustments (optional returns / missing storage handling).
  • qdrant/qdrant#9019: Related refactor and read-only null index changes affecting null-index open semantics.

Suggested labels

release:1.18.0

Suggested reviewers

  • generall
  • ffuugoo
  • coszio

Poem

🐰 I hopped through flags and flitted bits,
When on-disk silence whispered "none", I sit,
No panic at absence — I quietly skip,
Optional opens now tidy up the trip,
A little rabbit nod for fewer slips.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: detect not-found via error in bool, null and geo index open' accurately describes the main change: modifying bool, null, and geo index open functions to detect missing resources via error handling and return OperationResult<Option<Self>> instead of OperationResult<Self>.
Description check ✅ Passed The PR description contains a contributor checklist acknowledging the submission requirements and claimed completion of key tasks (tests pass, code formatted, clippy checks run), which is related to the changeset's readiness.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dancixx
dancixx marked this pull request as ready for review June 2, 2026 13:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lib/segment/src/common/flags/read_only_roaring_flags.rs (1)

76-87: 💤 Low value

Consider 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::open will return an error rather than Ok(None). This creates an asymmetry: a directory with only the status file causes an error, while a completely missing directory returns Ok(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

📥 Commits

Reviewing files that changed from the base of the PR and between 3053ca6 and 1b34c08.

📒 Files selected for processing (9)
  • lib/segment/src/common/flags/read_only_roaring_flags.rs
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rs
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/mod.rs
  • lib/segment/src/index/field_index/geo_index/mutable_geo_index/read_only/lifecycle.rs
  • lib/segment/src/index/field_index/geo_index/mutable_geo_index/read_only/mod.rs
  • lib/segment/src/index/field_index/geo_index/read_only/lifecycle.rs
  • lib/segment/src/index/field_index/geo_index/read_only/mod.rs
  • lib/segment/src/index/field_index/null_index/read_only_null_index/lifecycle.rs
  • lib/segment/src/index/field_index/null_index/read_only_null_index/mod.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Check for is_null-only leftovers before returning Ok(None).

This has the same one-sided inconsistency detection as the bool opener: when has_values is missing, the function returns Ok(None) without checking whether is_null is still on disk. That means an is_null-only partial index is silently treated as absent instead of corrupt. Please branch on both opens together so only (None, None) maps to Ok(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

📥 Commits

Reviewing files that changed from the base of the PR and between 1b34c08 and c0dcee3.

📒 Files selected for processing (4)
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rs
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/mod.rs
  • lib/segment/src/index/field_index/null_index/read_only_null_index/lifecycle.rs
  • lib/segment/src/index/field_index/null_index/read_only_null_index/mod.rs

@dancixx
dancixx force-pushed the feat/readonly-bool-null-geo-not-found branch 2 times, most recently from 1d64c14 to 11683ef Compare June 2, 2026 14:21
@dancixx
dancixx force-pushed the feat/readonly-bool-null-geo-not-found branch from 11683ef to 9a97cf7 Compare June 2, 2026 14:39
@dancixx
dancixx requested a review from generall June 2, 2026 14:40
@coszio
coszio merged commit 89b0f32 into dev Jun 2, 2026
15 checks passed
@coszio
coszio deleted the feat/readonly-bool-null-geo-not-found branch June 2, 2026 16:29
timvisee pushed a commit that referenced this pull request Jun 3, 2026
)

* feat: detect not-found via error in bool, null and geo index open

* fix: error on inconsistent storage in bool and null index open

* fix: hw counter write -> read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants