Skip to content

Add deferred point count to UpdateQueueInfo - #8414

Merged
JojiiOfficial merged 8 commits into
devfrom
deferred-points-in-update-queue-info
Mar 19, 2026
Merged

JojiiOfficial merged 8 commits into
devfrom
deferred-points-in-update-queue-info

Conversation

@JojiiOfficial

@JojiiOfficial JojiiOfficial commented Mar 16, 2026 •

Copy link
Copy Markdown
Member

Depends on #8366

Adds the amount of deferred points to the UpdateQueueInfo to make it public via CollectionInfo.

@JojiiOfficial
JojiiOfficial marked this pull request as ready for review March 16, 2026 15:37
@JojiiOfficial JojiiOfficial added this to the deferred updates milestone Mar 16, 2026
let (status, optimizer_status) = self.local_shard_status().await;

let update_queue = self.local_update_queue_info();
let update_queue = self.local_update_queue_info().await;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems local_update_queue_info is also re-iterating over all segments.

Can't we merge the deferred_point_count accumulation into the previous segments traversal?

Was it done this way for re-usability?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Was it done this way for re-usability?

Exactly. We also use this function for telemetry here. So it's duplicate code vs iterating twice. To have a single source of truth, I went with the iterating twice approach but I don't have a strong preference here.

@JojiiOfficial JojiiOfficial Mar 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

On a second thought, we could add a segments: Option<&[LockedSegment]> parameter to local_shard_status() and don't lock if Some(..). It's a bit hacky but his way we can reuse this function and keep code-duplication low. Wdyt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree sounds a bit hacky.

@JojiiOfficial
JojiiOfficial force-pushed the deferred-points-in-update-queue-info branch from 13d93a9 to b42848c Compare March 17, 2026 09:52
}

pub async fn local_update_queue_info(&self) -> ShardUpdateQueueInfo {
let deferred_point_count = self

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not computing this only if prevent_unoptimized is on?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. Done in 96c65ee

@JojiiOfficial
JojiiOfficial force-pushed the correct-point-count-usage-deferred-points branch from 6964a86 to 3df439e Compare March 19, 2026 08:43
@JojiiOfficial
JojiiOfficial force-pushed the deferred-points-in-update-queue-info branch from 96c65ee to 0428cfa Compare March 19, 2026 10:23
Base automatically changed from correct-point-count-usage-deferred-points to dev March 19, 2026 10:33
@JojiiOfficial
JojiiOfficial force-pushed the deferred-points-in-update-queue-info branch from 0428cfa to 781ac69 Compare March 19, 2026 10:35
@coderabbitai

coderabbitai Bot commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9c964015-9f7a-4af5-b2c8-65c0addf391d

📥 Commits

Reviewing files that changed from the base of the PR and between 781ac69 and 5873bf9.

📒 Files selected for processing (1)
  • lib/collection/src/shards/local_shard/mod.rs

📝 Walkthrough

Walkthrough

This PR adds an optional deferred_points field (nullable uint, minimum 0) to OpenAPI, protobuf, and Rust types for update-queue responses. It introduces deferred_point_count() to the NonAppendableSegmentEntry trait and implements it for Segment and ProxySegment, centralizing deferred-point counting. Local shard logic was made async to compute deferred points (respecting optimizer config) and helper iteration over appendable segments was added. Conversions, gRPC mappings, telemetry, tests, and related types were updated to propagate the new field.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

release:1.17.0

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% 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 'Add deferred point count to UpdateQueueInfo' directly and clearly summarizes the main change: introducing a deferred_points field to the UpdateQueueInfo structure.
Description check ✅ Passed The description explains that the PR adds deferred points to UpdateQueueInfo to expose this information via CollectionInfo, which is directly related to the changes shown in the raw summary.

✏️ 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 deferred-points-in-update-queue-info
📝 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
lib/collection/src/tests/wal_recovery_test.rs (1)

539-539: Assert deferred_points here too.

This test now awaits local_update_queue_info(), but it still only exercises length. Since the PR’s user-visible behavior is the new deferred_points field, add an assertion here (or a dedicated test) so regressions in its visibility/count do not go unnoticed.

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

In `@lib/collection/src/tests/wal_recovery_test.rs` at line 539, After calling
local_update_queue_info() and binding it to post_load_info, add an assertion
that verifies post_load_info.deferred_points matches the expected deferred count
(similar to the existing length assertion). For example, mirror the existing
length check by asserting post_load_info.deferred_points ==
<expected_deferred_value> (or assert!(post_load_info.deferred_points > 0) if the
test only requires non-zero), using the same expected value/source used for the
previous length assertion so regressions in deferred_points visibility/count are
caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/collection/src/operations/types.rs`:
- Around line 158-161: CollectionInfo currently drops deferred_points because
CollectionInfo::empty() returns UpdateQueueInfo::default() and collection-level
builders only aggregate length; fix this by wiring deferred_points through all
builders: change CollectionInfo::empty() to construct an UpdateQueueInfo that
sets deferred_points (e.g., Some(0) when prevent_unoptimized is true) instead of
UpdateQueueInfo::default(), update the collection-level aggregation in
lib/collection/src/collection/collection_ops.rs to sum shard
UpdateQueueInfo.deferred_points into CollectionInfo.update_queue.deferred_points
(analogous to length aggregation), and ensure any shard-to-collection
builder/merge logic propagates Option<usize> deferred_points (handling None
appropriately) so multi-shard collections reflect the correct total
deferred_points.

In `@lib/collection/src/shards/local_shard/mod.rs`:
- Around line 1026-1028: Typo in the log message: change the warn call that
references deferred_point_count (log::warn!("Failed to get deferred ponit
counts: {err:?}")) to use the correct spelling "point" (e.g., "Failed to get
deferred point counts: {err:?}"), updating the log::warn invocation in mod.rs
near the deferred_point_count handling to fix codespell CI failure.
- Around line 1015-1023: The deferred point counting currently calls
do_with_segments(..., true) which limits to appendable segments and misses
deferred points behind non-appendable ProxySegment instances; update the call in
do_with_segments (used to compute update_queue.deferred_points) to pass false
for the appendable_only flag so that segment.get().read().deferred_point_count()
aggregates across all segments (including non-appendable proxies) ensuring
deferred points aren't dropped during optimization.

---

Nitpick comments:
In `@lib/collection/src/tests/wal_recovery_test.rs`:
- Line 539: After calling local_update_queue_info() and binding it to
post_load_info, add an assertion that verifies post_load_info.deferred_points
matches the expected deferred count (similar to the existing length assertion).
For example, mirror the existing length check by asserting
post_load_info.deferred_points == <expected_deferred_value> (or
assert!(post_load_info.deferred_points > 0) if the test only requires non-zero),
using the same expected value/source used for the previous length assertion so
regressions in deferred_points visibility/count are caught.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f716b66-7c2c-40b6-9601-c1ea99d5281d

📥 Commits

Reviewing files that changed from the base of the PR and between 3560403 and 781ac69.

📒 Files selected for processing (13)
  • docs/redoc/master/openapi.json
  • lib/api/src/grpc/proto/collections.proto
  • lib/api/src/grpc/qdrant.rs
  • lib/collection/src/operations/conversions.rs
  • lib/collection/src/operations/types.rs
  • lib/collection/src/shards/local_shard/mod.rs
  • lib/collection/src/shards/local_shard/telemetry.rs
  • lib/collection/src/tests/wal_recovery_test.rs
  • lib/segment/src/entry/entry_point.rs
  • lib/segment/src/segment/entry.rs
  • lib/segment/src/segment/segment_ops.rs
  • lib/shard/src/proxy_segment/segment_entry.rs
  • lib/shard/src/segment_holder/mod.rs
💤 Files with no reviewable changes (1)
  • lib/segment/src/segment/segment_ops.rs

Comment on lines +158 to +161
/// Number of points that are deferred (i.e hidden from search as they're not yet optimized).
#[anonymize(false)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub deferred_points: Option<usize>,

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.

⚠️ Potential issue | 🟠 Major

Finish wiring deferred_points through the remaining collection-level builders.

Adding the field here is only part of the plumbing: CollectionInfo::empty() still emits UpdateQueueInfo::default(), so empty collections hide the field even when prevent_unoptimized = true, and lib/collection/src/collection/collection_ops.rs still aggregates only length. Multi-shard CollectionInfo.update_queue.deferred_points will therefore be wrong or missing.

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

In `@lib/collection/src/operations/types.rs` around lines 158 - 161,
CollectionInfo currently drops deferred_points because CollectionInfo::empty()
returns UpdateQueueInfo::default() and collection-level builders only aggregate
length; fix this by wiring deferred_points through all builders: change
CollectionInfo::empty() to construct an UpdateQueueInfo that sets
deferred_points (e.g., Some(0) when prevent_unoptimized is true) instead of
UpdateQueueInfo::default(), update the collection-level aggregation in
lib/collection/src/collection/collection_ops.rs to sum shard
UpdateQueueInfo.deferred_points into CollectionInfo.update_queue.deferred_points
(analogous to length aggregation), and ensure any shard-to-collection
builder/merge logic propagates Option<usize> deferred_points (handling None
appropriately) so multi-shard collections reflect the correct total
deferred_points.

@JojiiOfficial
JojiiOfficial merged commit c015b86 into dev Mar 19, 2026
15 checks passed
@JojiiOfficial
JojiiOfficial deleted the deferred-points-in-update-queue-info branch March 19, 2026 14:27
generall pushed a commit that referenced this pull request Mar 26, 2026
* Add deferred point count to UpdateQueueInfo

* Hide if prevent_unoptimized is false

* Clippy

* Openapi

* Iterate over appendable segments only

* Only calculate deferred point count if prevent_unoptimized is true

* Rebase fixes

* Codespell
KShivendu pushed a commit that referenced this pull request Mar 30, 2026
* Add deferred point count to UpdateQueueInfo

* Hide if prevent_unoptimized is false

* Clippy

* Openapi

* Iterate over appendable segments only

* Only calculate deferred point count if prevent_unoptimized is true

* Rebase fixes

* Codespell
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.

3 participants