Skip to content

Apply point deletions to all point versions - #5956

Merged
timvisee merged 9 commits into
devfrom
point-delete-all-versions
Feb 10, 2025
Merged

timvisee merged 9 commits into
devfrom
point-delete-all-versions

Conversation

@timvisee

@timvisee timvisee commented Feb 7, 2025 •

Copy link
Copy Markdown
Member

Fix a critical problem which could result in us reviving (partial) already deleted points.

A point may exist in multiple segments, having multiple versions. This is normal behavior and can happen due to a myriad of reasons.

Normally, point operations are only applied to the latest point version. This is done on purpose, so that any copy-on-write operation always uses the latest point data as source.

The problem is in deleting points though. If we only delete the latest point version, we may leave older point versions behind. We never use these older versions, but we might now accidentally revive them if we forget the newer deleted version. To prevent this problem, we now delete all point versions.

To accommodate this change, I've extracted the point/segment selection logic into a separate function. It takes care of either selecting all point versions, or just the latest.

All Submissions:

  • Contributions should target the dev branch. Did you create your branch 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 --all --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?

@timvisee
timvisee force-pushed the point-delete-all-versions branch from ef8430c to 3992a99 Compare February 7, 2025 16:13
@timvisee
timvisee force-pushed the point-delete-all-versions branch from b6e896e to ce55f28 Compare February 7, 2025 16:32
@timvisee
timvisee force-pushed the point-delete-all-versions branch from 5ebe792 to fe84bd0 Compare February 7, 2025 17:04
@timvisee
timvisee marked this pull request as ready for review February 7, 2025 17:04
Comment on lines +54 to +55
// Apply point delete to all point versions
true,

@timvisee timvisee Feb 7, 2025 •

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.

Critical bit: for point delete operations we use true to apply the delete to all point versions.

For other operations this flag is false, meaning it only applies to the latest version as expected.

@generall generall left a comment

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.

see comment

@generall

generall commented Feb 8, 2025

Copy link
Copy Markdown
Member

After giving it a bit more though, I have an alternative proposal.
Here is my logic:

Assume we have a situation, where 2 points with different versions already exist (for whatever reason)

Option 1 - we update only highest version.
If we do so, it might be possible, that the old version will continue to pop up in search results, as there are no guarantee that both versions necessary have to show up in the same requests -> they won't be properly de-duplicated on search.

Option 2 - we always update both version.
In this case versions of both points are upgraded to the latest operation. If we don't upsert and change the point partially, after the update we potentially have 2 identical versions with same content. Automatic resolution won't be possible after that.

So, both approaches are not ideal, but I have another option

Option 3 (proposed) - delete old version on update
On any update always collect all points versions on all segments. Pick the latest one and update it. Delete all other versions. This approach should prevent both drawbacks

Thoughts?

@timvisee

timvisee commented Feb 10, 2025 •

Copy link
Copy Markdown
Member Author

Option 1 - we update only highest version.
If we do so, it might be possible, that the old version will continue to pop up in search results, as there are no guarantee that both versions necessary have to show up in the same requests -> they won't be properly de-duplicated on search.

Are you suggesting that a payload value on an old point might make the old point appear if we filter on that value? I think you're right. Good thinking!

Option 3 (proposed) - delete old version on update
On any update always collect all points versions on all segments. Pick the latest one and update it. Delete all other versions. This approach should prevent both

I like this idea, but: we must ensure flush ordering, flushing updates first, then the deletions. Otherwise I can easily see this causing missing points if we crash during flush.

After another thought, I don't see flush issues. We'll never delete the highest point version, which means we can never lose the point on flush. I like the idea!

Are you fine with merging this PR first? So we can consider option 3 after?

@generall
generall self-requested a review February 10, 2025 09:02
@timvisee
timvisee merged commit 631df20 into dev Feb 10, 2025
@timvisee
timvisee deleted the point-delete-all-versions branch February 10, 2025 10:07
timvisee added a commit that referenced this pull request Feb 11, 2025
* Extract point in segment selection logic, find just latest or all

* Add only_latest_version flag to apply_points

* The apply_points_with_conditional_move function does not delete points

* Flip boolean, only_latest_version to all_point_versions

* Link to GitHub PR describing bug

* Add test, assert point delete applies to all point versions

* split into two functions

* nit: calculate default capacity outside of loop

* When deleting point vector, only apply to latest point version

---------

Co-authored-by: Luis Cossío <[email protected]>
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