Repository navigation
Propagate OperationResult [2/4]: SegmentEntry - #8445
Conversation
ab9e869 to
99299a6
Compare
672931b to
232e5d0
Compare
99299a6 to
f5ddf7c
Compare
232e5d0 to
16e919f
Compare
f5ddf7c to
c73b359
Compare
16e919f to
9040672
Compare
c73b359 to
70f5f6b
Compare
70f5f6b to
d6f69f8
Compare
📝 WalkthroughWalkthroughThis PR systematically converts error-handling across collection and shard operations by changing trait method signatures and implementations to return Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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.
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 | 🟠 MajorDeduplicate 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=truecan 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 | 🟠 MajorFix error propagation in segment read operations to avoid masking real errors as timeouts.
The three scroll operations use
try_join_all()with tasks that returnJoinHandle<OperationResult<_>>. Sincetry_join_allonly short-circuits onJoinError(not on the innerOperationError), segment failures stay wrapped inOk(...)until all tasks complete. The surroundingtokio::time::timeout()can then fire first, masking the real error as a timeout.Unwrap each handle immediately with
.await??before passing totry_join_all, so operation errors can propagate directly:.map(|segment| async { read_filtered(segment, hw_counter.fork()).await?? })This ensures
try_join_allreceivesOperationResult<T>directly and can short-circuit on actual segment failures.Applies to:
scroll_by_field(lines 256–300) andscroll_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
📒 Files selected for processing (13)
lib/collection/src/collection_manager/segments_searcher.rslib/collection/src/collection_manager/tests/mod.rslib/collection/src/shards/local_shard/mod.rslib/collection/src/shards/local_shard/scroll.rslib/edge/src/count.rslib/edge/src/scroll.rslib/segment/src/entry/entry_point.rslib/segment/src/segment/entry.rslib/segment/src/segment/tests.rslib/segment/tests/integration/payload_index_test.rslib/shard/src/proxy_segment/segment_entry.rslib/shard/src/proxy_segment/tests.rslib/shard/src/update.rs
Third commit in the stack #8433.