Skip to content

Bump segment version on {delete,update,upsert}-by-filter requests#7157

Merged
generall merged 14 commits intodevfrom
bump-segment-version-on-by-filter-update
Sep 5, 2025
Merged

Bump segment version on {delete,update,upsert}-by-filter requests#7157
generall merged 14 commits intodevfrom
bump-segment-version-on-by-filter-update

Conversation

@JojiiOfficial
Copy link
Contributor

Currently we don't acknowledge update-requests by filters that don't match any points, in write ahead log.
This triggers WAL replay when restart Qdrant. If there were many of such no-op operations, or large filters, this
sometimes significantly slowed down startup needlessly.
This PR fixes this issue by bumping segment versions manually, if no point was matched.

@JojiiOfficial JojiiOfficial requested a review from timvisee August 27, 2025 13:27
coderabbitai[bot]

This comment was marked as resolved.

@qdrant qdrant deleted a comment from coderabbitai bot Aug 27, 2025
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@qdrant qdrant deleted a comment from coderabbitai bot Aug 27, 2025
@timvisee timvisee requested a review from ffuugoo August 27, 2025 15:21
@timvisee
Copy link
Member

Thanks! Happy to see a test for this as well.

Before I approve, I tagged @ffuugoo for a review as well. We must validate this doesn't have a negative effect on partial snapshots for R/W segregation.

@generall
Copy link
Member

We must validate this doesn't have a negative effect on partial snapshots

it will likely have.

@timvisee
Copy link
Member

timvisee commented Aug 28, 2025

@JojiiOfficial could you do some tests on this one to assert the behavior alongside partial snapshots?

The concern is that all segments that get their version bumped are transferred (almost) in full, even though there is no data change. That may be expensive on (large) R/W deployments.

An alternative might be to keep a separate version number in the segment holder. These empty updates could simply bump this separate version number. Though I'd rather keep it as is - not adding an extra version number if not required.

@ffuugoo
Copy link
Contributor

ffuugoo commented Aug 28, 2025

Why WAL flush/truncate does not solve this? Do we only truncate up to common (min? max?) version among all segments?

UPD: I think I remember now, that we truncate to either min or max flushed segment version, so if you do 100 ops that did not hit any segment you get 100 untruncated ops in WAL?

@timvisee
Copy link
Member

timvisee commented Aug 28, 2025

I think I remember now, that we truncate to either min or max flushed segment version, so if you do 100 ops that did not hit any segment you get 100 untruncated ops in WAL?

Correct.

So here we (currently) artificially bump a segment version if a -by-filter operation matched zero points, and then acknowledge it in the WAL, so that we prevent this problem.

Or well, prevent a problem with WAL replay and very expensive operations taking a very long time, even if they were already properly flushed.

@ffuugoo
Copy link
Contributor

ffuugoo commented Aug 28, 2025

Hm. Maybe we could add an in-memory counter specifically for filtered ops that did not match anything then... 😞

coderabbitai[bot]

This comment was marked as resolved.

@JojiiOfficial JojiiOfficial force-pushed the bump-segment-version-on-by-filter-update branch from 956de24 to 1f773bf Compare August 29, 2025 13:40
coderabbitai[bot]

This comment was marked as resolved.

@qdrant qdrant deleted a comment from coderabbitai bot Aug 29, 2025
@qdrant qdrant deleted a comment from coderabbitai bot Aug 29, 2025
@JojiiOfficial JojiiOfficial requested a review from timvisee August 29, 2025 14:13
coderabbitai[bot]

This comment was marked as resolved.

@timvisee timvisee requested a review from generall August 29, 2025 14:40
coderabbitai[bot]

This comment was marked as resolved.

Copy link
Member

@timvisee timvisee left a comment

Choose a reason for hiding this comment

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

Before merging I'd also like to see a review by @generall or @ffuugoo on the final approach.

coderabbitai[bot]

This comment was marked as resolved.

@qdrant qdrant deleted a comment from coderabbitai bot Sep 1, 2025
coderabbitai[bot]

This comment was marked as resolved.

@qdrant qdrant deleted a comment from coderabbitai bot Sep 1, 2025
@generall generall merged commit 1e1d683 into dev Sep 5, 2025
16 checks passed
@generall generall deleted the bump-segment-version-on-by-filter-update branch September 5, 2025 12:29
timvisee added a commit that referenced this pull request Sep 29, 2025
)

* Bump segment versions on *-by-filter operations to acknowledge WAL

* Assert exactly one segment with the new operation version

* Review remarks

* Separate segment version number to not affect partial snapshots

* Adjust unit test

* Remove old bump_segment_version implementations

* Clarify max_persisted_segment_version_overwrite in flush_all

* Move trait implementations - Clippy

* Apply segment bumping to all *-by-filter functions

* Remove AtomicOptionU64

* Update function name and comments

* Remove max condition, start with overwrite value

* Add assertion, can never have zero segments

* Make max_persisted_segment_version_overwrite monotonic with fetch_max

---------

Co-authored-by: timvisee <tim@visee.me>
@timvisee timvisee mentioned this pull request Sep 29, 2025
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.

4 participants