Repository navigation
fix(#9506): an LSM_VECTOR build over a populated index replaces each record's vector instead of adding a second one - #9591
Conversation
…record's vector instead of adding a second one Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Review of #9591The fix is small, well reasoned and well tested. I have no blocking concerns. What works
Points to consider (non-blocking)
Approve from my side, pending CI. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | Report missing for 9fba1561 |
| Diff coverage | ✅ 100.00% diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (9fba156) Report Missing Report Missing Report Missing Head commit (7a641ef) 254922 203870 79.97% Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#9591) 9 9 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughBulk loading a populated LSM vector index now queues removal of existing vector IDs before adding replacements. Local and HA tests check entry counts and vector behavior after rebuilds. ChangesVector index rebuild
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The populated-index rebuild replacement path has no identified merge-blocking issue. Merge after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❓ 1❌ Failed checks (1 inconclusive)✅ Passed checks (4 passed)Full details: Docstring CoverageExplanation Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 5 files. (1 skipped: 1 too large.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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 |
… ids, not only the count Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ReviewThe fix is small, targeted and well reasoned. I read the diff only and did not build or run the tests. What I like
Points to check (none blocking)
Style matches CLAUDE.md: |
…headroom to the uncharged tombstones Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ReviewOverall this is a well-scoped fix with strong tests. I found no blocking issues. What I checked
Minor suggestions (non-blocking)
LGTM pending CI. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9591 +/- ##
============================================
- Coverage 77.37% 77.37% -0.01%
+ Complexity 4279 4277 -2
============================================
Files 2160 2160
Lines 222278 222305 +27
Branches 47619 47631 +12
============================================
+ Hits 171990 172007 +17
+ Misses 32061 32058 -3
- Partials 18227 18240 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #9506
Summary
LSMVectorIndex.build()over an index that already held entries queued a freshADDper record and never retired the record's committed vector id, so every record ended with two live ids:countEntries()doubled, a delete then tombstoned two ids per record, and a search (whose graph is keyed by RID) kept one of them and disagreed with the count - which is what made the nodes of #9428's cluster disagree. The bulk load now captures, once, whether the index starts populated; when it does, every record that already has a live vector id gets aREMOVEqueued on the build's transaction before itsADD. The commit replays everyREMOVEbefore anyADD(TransactionIndexContext.commit()), so the record's committed ids are tombstoned and theADDwrites its one fresh id, in the same chunk. A build over an empty index (every schema path:CREATE INDEX,REBUILD INDEX, which drops and recreates) pays nothing.The
REMOVEis queued under a NaN-filled key on purpose. The transaction keeps one entry per (key, RID), so aREMOVEunder the same key as the followingADDis displaced by it and never reaches the index. The record's own vector is therefore the wrong key, and so isremovalKey()'s all-zero placeholder: an all-zero vector is a valid embedding under EUCLIDEAN (#8962). NaN components are refused byput()before anything is queued, so noADDkey can collide. Checked by mutation: with a zero-filled key the new engine test fails at 11 entries instead of 10 (the origin record keeps its duplicate).A side effect: a build now also repairs records that already carry duplicates from an earlier build, because
remove()tombstones every live id of the RID.Completeness
Invariant: after
build(), every record of the bucket has exactly one live vector id in the index.build(callback, graphCallback)owning its transaction (chunked)aBuildOverAPopulatedIndexKeepsOneEntryPerRecordbuild(batchSize, sharesCallerTransaction=true, cb)inside a caller's transactionaBuildSharingTheCallersTransactionKeepsOneEntryPerRecordaBuildOverAPopulatedIndexAcrossSeveralChunksKeepsOneEntryPerRecordaDeleteAfterABuildOverAPopulatedIndexRemovesExactlyOneEntryaSearchAfterABuildOverAPopulatedIndex...(count asserted before AND after the search)Issue9506BuildOverPopulatedIndexHATestCREATE INDEX/REBUILD INDEX(LocalSchema.createBucketIndex,RebuildIndexStatementdrop+recreate)Test plan
Issue9506BuildOverPopulatedIndexTest(engine, new): 3 of 4 red before the fix (20 entries instead of 10, 18 after a delete instead of 9), green afterIssue9506BuildOverPopulatedIndexHATest(ha-raft, new)Issue9428FollowerVectorInsertHATest: theTODO(#9506)expectations (2 * BATCH) are nowBATCH/BATCH + 1Issue8905VectorBuildHATest,Issue8905BuildWithUnloadedGraphHATest: now assert the exact record count instead of whatever the index reportedcom.arcadedb.index.vectorengine package (148 classes, 636 tests)The chunking estimate (
dimensions * 4 + 32per record) was left unchanged. A tombstone page entry is at most 21 bytes, and an unquantized vector entry measures ~9, so the estimate still covers both. A first version charged tombstones separately, but that pushedIssue8905VectorBuildCommitsReachTheWrapperTest's one-chunk fixtures over 1MB, so it was reverted.Coverage
Entry points: see the Completeness table above.
Known gaps: None for the invariant. Out of scope, as with every LSM index build: entries for RIDs that are no longer in the bucket (orphans) are not removed by a build.
Adversarial pass
Not run: this workflow session had no subagent tool to spawn the independent reviewer. The author checked these by hand instead: the REMOVE/ADD key collision (fixed by the NaN key and pinned with the origin record), the undo journal's disjointness assertion (tombstoned ids are pre-existing, allocated ids are new), and the HA replication of the tombstones (the HA tests above).
Review cycles
9dec1e4b7a- claude approved with non-blocking points. Applied: the first test now asserts that the ids from before the build are tombstoned and the new ids are fresh (replace semantics, not only the count) ->f69772414ff69772414f- claude approved with non-blocking points. Applied: a multi-chunk populated build test, and thegetBulkLoadChunkSizeBytesjavadoc now names the uncharged tombstones as part of what the half-cap headroom absorbs ->7a641ef8d6. Checked:VectorLocationIndex.size()is the live count, so a fully deleted index does not take the supersede path7a641ef8d6- claude: "LGTM pending CI", only non-blocking points, all raised and declined in earlier cyclesDeferred items
getVectorIdsForRid(rid)allocates anint[]for every scanned record on a populated index" (cycles 1-3) - skipped:VectorLocationIndexhas no allocation-free per-RID check. The lookup is O(1), and only the rare populated-index build pays for it; the empty-index path (CREATE INDEX,REBUILD INDEX) does not.@Tag(\"slow\")" for the multi-chunk test (cycle 3) - skipped: the whole class runs in ~1.4s.Final state
clean-approval (merge stays with the maintainer)
🤖 Generated with Claude Code
Summary by CodeRabbit