Repository navigation
fix(storage): no orphan vector index entry when the label-add tag write is refused - #5081
Open
andrejtonev wants to merge 2 commits into
Open
andrejtonev wants to merge 2 commits into
andrejtonev wants to merge 2 commits into
Conversation
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #5077; review only the commits after it.
When a label is added,
VectorIndex::ApplyAddLabeladds the vertex to usearch first and then writes the vector-index tag into the property store. Both steps run underAddLabel'sOutOfMemoryExceptionEnabler. If the memory limit refuses the tag write, the transaction aborts with a usearch entry but no tag. TheADD_LABELundo keys off the tag, so it skips the vertex and the entry stays behind as an orphan. After that, the index's search returns a vertex its label filter does not admit, and the index count is off by one. The entry is cleared only when the label is re-added, the vertex is deleted, the index is dropped or the server restarts.The window predates #4992: master has the same add-then-tag order under the same enabler. #4992 widens it. With that PR the usearch tape allocation is no longer refusable and may overshoot the limit, so the very next fresh-extent allocation, the tag write, gets refused.
Changes
ApplyAddLabelbuilds the new id list and the tag value before the usearch add. Nothing has been mutated yet at that point, so a refusal there is harmless.OutOfMemoryExceptionBlocker. The write is still tracked but can no longer be refused, which is the same rule asAtomicMemoryBlock. The overshoot is bounded by the vertex's own property buffer. The abort path (restore=true) already ran underUndoNoThrow's blocker, so it behaves as before.Result
VectorIndexTest.AddLabelTagWriteRefusedLeavesNoOrphanEntryAfterAbort. It puts a vertex in index A with a 3 MiB exact-size property buffer. Adding label B on the same property grows the tag by 8 bytes, which forces a fresh-extent reallocation right after the usearch add. A tight graph memory limit is set. Without the fix, the write is refused, and after the abortidx_Bstill holds the vertex (size 1, search hit), reproducing in 3 of 3 runs. With the fix, the write succeeds above the limit and the abort leavesidx_Bempty.vector_index,vector_edge_index,storage_v2andstorage_v2_indicespass.