Skip to content

Propagate OperationResult [2/4]: SegmentEntry - #8445

Merged
xzfc merged 1 commit into
devfrom
uio-propagate-result-2
Mar 19, 2026
Merged

xzfc merged 1 commit into
devfrom
uio-propagate-result-2

Conversation

@xzfc

@xzfc xzfc commented Mar 18, 2026

Copy link
Copy Markdown
Member

Third commit in the stack #8433.

@xzfc xzfc mentioned this pull request Mar 18, 2026
@xzfc
xzfc marked this pull request as ready for review March 18, 2026 09:52
@xzfc
xzfc force-pushed the uio-propagate-result-2 branch from ab9e869 to 99299a6 Compare March 18, 2026 10:22
@xzfc
xzfc force-pushed the uio-propagate-result-1 branch 2 times, most recently from 672931b to 232e5d0 Compare March 18, 2026 13:17
@xzfc
xzfc force-pushed the uio-propagate-result-2 branch from 99299a6 to f5ddf7c Compare March 18, 2026 13:17
@xzfc
xzfc force-pushed the uio-propagate-result-1 branch from 232e5d0 to 16e919f Compare March 18, 2026 13:30
@xzfc
xzfc force-pushed the uio-propagate-result-2 branch from f5ddf7c to c73b359 Compare March 18, 2026 13:32
@xzfc
xzfc force-pushed the uio-propagate-result-1 branch from 16e919f to 9040672 Compare March 18, 2026 13:47
@xzfc
xzfc force-pushed the uio-propagate-result-2 branch from c73b359 to 70f5f6b Compare March 18, 2026 13:47
Base automatically changed from uio-propagate-result-1 to dev March 18, 2026 15:21
@xzfc
xzfc force-pushed the uio-propagate-result-2 branch from 70f5f6b to d6f69f8 Compare March 18, 2026 15:23
@coderabbitai

coderabbitai Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR systematically converts error-handling across collection and shard operations by changing trait method signatures and implementations to return OperationResult<T> or CollectionResult<T> instead of plain values. The changes affect segment reading (read_filtered, read_random_filtered), cardinality estimation (estimate_point_count), and result aggregation patterns. Iterator aggregation is refactored to use process_results for lazy error propagation. Call sites are updated with ? operators to propagate errors or .unwrap() in test code. The modifications touch trait definitions, implementations, and callers across multiple modules within the collection and shard layers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • generall
  • timvisee
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: propagating OperationResult types through the SegmentEntry trait methods. It is specific and directly related to the changeset.
Description check ✅ Passed The description is minimalist but related to the changeset, referencing it as part of a larger stack (#8433). While brief, it provides meaningful context about the PR's place in a series of changes.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch uio-propagate-result-2
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
lib/edge/src/count.rs (1)

21-31: ⚠️ Potential issue | 🟠 Major

Deduplicate IDs before returning an exact count.

This still counts every per-segment hit. When the same point is visible from more than one segment during overlap states, exact=true can overcount even though the scroll path already deduplicates before returning results.

💡 Suggested fix
-                .process_results(|iter| iter.flatten().count())?
+                .process_results(|iter| iter.flatten().sorted().dedup().count())?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/edge/src/count.rs` around lines 21 - 31, The current pipeline counts
every per-segment hit (process_results(|iter| iter.flatten().count())), which
overcounts when the same point appears in multiple segments; change the final
aggregation to deduplicate by ID before counting (e.g., collect unique IDs into
a HashSet or use an iterator that maps each result to its unique identifier and
counts distinct entries) instead of counting flattened hits directly; locate the
call chain involving segment.get().read().read_filtered(...,
DeferredBehavior::Exclude) and replace the process_results closure to produce a
deduplicated count of unique IDs.
lib/collection/src/shards/local_shard/scroll.rs (1)

168-202: ⚠️ Potential issue | 🟠 Major

Fix error propagation in segment read operations to avoid masking real errors as timeouts.

The three scroll operations use try_join_all() with tasks that return JoinHandle<OperationResult<_>>. Since try_join_all only short-circuits on JoinError (not on the inner OperationError), segment failures stay wrapped in Ok(...) until all tasks complete. The surrounding tokio::time::timeout() can then fire first, masking the real error as a timeout.

Unwrap each handle immediately with .await?? before passing to try_join_all, so operation errors can propagate directly:

.map(|segment| async {
    read_filtered(segment, hw_counter.fork()).await??
})

This ensures try_join_all receives OperationResult<T> directly and can short-circuit on actual segment failures.

Applies to: scroll_by_field (lines 256–300) and scroll_randomly (lines 379–414) as well.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/collection/src/shards/local_shard/scroll.rs` around lines 168 - 202, The
tasks passed into try_join_all are JoinHandle<OperationResult<_>> so errors from
segment.read_filtered remain wrapped and can be masked by the timeout; change
the map to an async closure that awaits the handle and propagates
OperationResult immediately (i.e., map(|segment| async { read_filtered(segment,
hw_counter.fork()).await?? }) ) so try_join_all gets OperationResult<T> directly
and can short-circuit on real segment errors; apply the same change in
scroll_by_id (this block), scroll_by_field, and scroll_randomly by replacing the
current map that returns handles with one that awaits and double-? returns the
inner OperationResult before try_join_all.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@lib/collection/src/shards/local_shard/scroll.rs`:
- Around line 168-202: The tasks passed into try_join_all are
JoinHandle<OperationResult<_>> so errors from segment.read_filtered remain
wrapped and can be masked by the timeout; change the map to an async closure
that awaits the handle and propagates OperationResult immediately (i.e.,
map(|segment| async { read_filtered(segment, hw_counter.fork()).await?? }) ) so
try_join_all gets OperationResult<T> directly and can short-circuit on real
segment errors; apply the same change in scroll_by_id (this block),
scroll_by_field, and scroll_randomly by replacing the current map that returns
handles with one that awaits and double-? returns the inner OperationResult
before try_join_all.

In `@lib/edge/src/count.rs`:
- Around line 21-31: The current pipeline counts every per-segment hit
(process_results(|iter| iter.flatten().count())), which overcounts when the same
point appears in multiple segments; change the final aggregation to deduplicate
by ID before counting (e.g., collect unique IDs into a HashSet or use an
iterator that maps each result to its unique identifier and counts distinct
entries) instead of counting flattened hits directly; locate the call chain
involving segment.get().read().read_filtered(..., DeferredBehavior::Exclude) and
replace the process_results closure to produce a deduplicated count of unique
IDs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 372f4559-e68a-4fe6-8a66-0f3b95a2de5f

📥 Commits

Reviewing files that changed from the base of the PR and between 7988eee and d6f69f8.

📒 Files selected for processing (13)
  • lib/collection/src/collection_manager/segments_searcher.rs
  • lib/collection/src/collection_manager/tests/mod.rs
  • lib/collection/src/shards/local_shard/mod.rs
  • lib/collection/src/shards/local_shard/scroll.rs
  • lib/edge/src/count.rs
  • lib/edge/src/scroll.rs
  • lib/segment/src/entry/entry_point.rs
  • lib/segment/src/segment/entry.rs
  • lib/segment/src/segment/tests.rs
  • lib/segment/tests/integration/payload_index_test.rs
  • lib/shard/src/proxy_segment/segment_entry.rs
  • lib/shard/src/proxy_segment/tests.rs
  • lib/shard/src/update.rs

@xzfc
xzfc merged commit 9aaa7c6 into dev Mar 19, 2026
15 checks passed
@xzfc
xzfc deleted the uio-propagate-result-2 branch March 19, 2026 05:40
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