Repository navigation
fix(#9692): top up sparse vector searches whose candidates a concurrent commit deleted - #9698
Conversation
…nt commit deleted The exact rescoring of LSM_SPARSE_VECTOR (on by default) dropped candidates whose record was gone and nothing replaced them, so topK / topKGrouped / topKForGroups could answer short or empty while thousands of matching records were live (#9634). vector.sparseNeighbors asked each sub-index for exactly k and skipped stale RIDs at emit time with no retry (#9635). Both layers now widen and ask again, mirroring the dense #9396 and #9368 fixes. 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. |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Complexity | 1 medium |
🟢 Metrics 27 complexity
Metric Results Complexity 27
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.
ReviewThe approach is sound. It moves the dense BINARY rerank top-up (#9396) to the sparse side, a clean pass costs exactly one pass as before, and every loop is bounded. The comments are thorough. I read the diff only and did not build it or run the tests. Possible bug: the widening step can shrink the budgetIn keep = (int) Math.min((long) keep * STALE_TOP_UP_GROWTH, Math.max(k, MAX_OVERFETCH_ROWS));The cap is Smaller points
TestsThe PR lists tests per entry point, which is good. Please confirm that:
Otherwise LGTM once the |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to Sparse vector searches now top up results when concurrent deletes leave stale candidates, with bounded retries and tests for the main cases. No actionable merge-blocking risk remains. Grouped SQL neighbor searches are intentionally left to a follow-up issue. Pre-merge checks |
|
…t; document multi-index saturation Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Review of #9698I read the diff and did not build or run the tests. I found no blocking issues. What looks good
Minor suggestions (non-blocking)
Overall this is a solid, well-reasoned fix. |
…e top-ups rely on Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Review of #9698 (sparse vector stale-candidate top-up)I read the diff but did not build it or run the tests. Overall: the approach is sound. It reuses the dense BINARY rerank pattern from #9396, and extracting Points to consider
Tests: coverage is good. It covers raw and rescored paths, a full window of stale entries, an index holding fewer than k, and an end-to-end race. Please confirm the grouped cases fail before the fix and pass after. No security concerns. Retries are bounded (6 attempts, plus the |
…the unbounded group budget Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Review of #9698 (sparse vector stale-candidate top-up)I read the diff but did not build the project or run the tests. Overall: The approach is sound. It mirrors the dense #9396 and #9368 loops, and the extra cost is only paid when a candidate was actually dropped. The termination conditions are well thought out: full answer, index exhausted, budget unable to grow, and a bounded attempt count. Code quality
Potential issues
PerformanceThe no-stale path is a single pass with just two boolean writes, so there is no regression. TestsBoth new test classes cover the entry points in the PR's coverage table (
I also suggest a negative test: an index that really holds fewer than SecurityNo concerns. The caps keep the work bounded, so a client cannot amplify memory or CPU beyond Approving in spirit. The notes above are minor. |
Closes #9692
Fixes both consolidated findings (#9634, #9635): a sparse vector search no longer answers short, or empty, when a concurrent commit deletes the records it picked as candidates.
LSMSparseVectorIndexrescoring (on by default: INT8 +rescoreOversampleauto = 2) loads each candidate's record and drops the ones that are gone, and nothing replaced them.topK,topKGroupedandcommittedForGroups(behindtopKForGroupsand the grouped Sparse grouped search can leave a group short of its groupSize when the distinct-group limit binds #8002 top-up) now widen the candidate budget x4 and ask the engine again when the answer came up short because candidates were dropped. They stop when the answer is full, when the engine handed over everything it holds, when the budget cannot grow, or after 6 attempts. This is the dense BINARY rerank loop from LSM_VECTOR with BINARY quantization: findNeighborsFromVector returns an empty list while another thread commits deletes and inserts near the query, although 3,000 records are live #9396, moved to the sparse side. The ungrouped path now lives in a newcommittedTopKhelper.vector.sparseNeighborsasked each sub-index for exactlykand dropped stale RIDs at emit time. The non-grouped path now runs the vectorNeighbors answers fewer than limit rows while another thread commits deletes: the SQL function skips records the index still returns and does not top up #9368 loop: astaleSkippedflag plus a saturation flag, and on a short answer it re-runs withfetchKdoubled, capped atMAX_FETCH_CANDIDATES.The extra cost is only paid when a candidate was actually dropped. A search with no stale candidates runs exactly one pass, as before.
Finding ledger
topK,topKGrouped,committedForGroups/topKForGroups)vector.sparseNeighborsemit loop drops stale RIDs withfetchKfixed atkCoverage
Invariant: a sparse search whose candidates are dropped because their record is gone keeps asking until it has
klive rows, or until the index really holds fewer.topK, unfiltered, rescoredtopKTopsUpCandidatesWhoseRecordIsGonetopK,allowedRIDswhitelisttopKWithAWhitelistTopsUpCandidatesWhoseRecordIsGonetopKwith a transaction overlaytopKInsideATransactionTopsUpCandidatesWhoseRecordIsGonetopKwhen the index really holds fewer than ktopKStillAnswersShortWhenTheIndexReallyHoldsFewertopKGroupedtopKGroupedTopsUpCandidatesWhoseRecordIsGonetopKForGroups/committedForGroups(also the top-up insidetopKGrouped's overlay branch)topKForGroupsTopsUpCandidatesWhoseRecordIsGonevector.sparseNeighborsnon-grouped, rescoring off (isolates the SQL layer)staleIndexEntriesAreToppedUpWithoutRescoring,aWholeWindowOfStaleEntriesIsToppedUpWithoutRescoring,anIndexHoldingFewerThanKStillAnswersWhatItHasvector.sparseNeighborsnon-grouped, default rescoringstaleIndexEntriesAreToppedUpWithTheDefaultRescoringtopK+ SQL)concurrentDeletesNeverShortenTheAnswer: fails 3/3 without the fix, passes 5/5 with itVectorLeg(hybrid search), MCPVectorSearchTool/HybridSearchToolvector.sparseNeighborsVectorFuse/VectorMmr/VectorRerank/VectorRecommend/VectorDiscovernullkeyKnown gaps
vector.sparseNeighbors/vector.neighborswithgroupBy: the SQL emit loop still drops a row whose record was deleted between the index answer and the emit. Dense and sparse have the same gap, so they should be fixed together. Tracked in [concurrency] vector.neighbors / vector.sparseNeighbors grouped path drops rows whose record a concurrent commit deleted without topping up #9697.Test plan
Issue9692SparseRescoreStaleCandidateTest(6 tests) andIssue9692SparseNeighborsStaleTopUpTest(5 tests) fail before the fix and pass after itcom.arcadedb.index.sparsevectortests, plus every*Sparse*Test,Issue9368*andIssue9692*: 170 tests, greencom.arcadedb.function.sql.vector.*Test,LSMSparseVectorIndex*Test,Issue7966*,Issue8576*,Issue8002*: 392 tests, greenAdversarial pass
Not run: this session had no subagent tool, so the independent follow-up pass could not be spawned. The completeness sweep above was done inline.
Residual risk
k * 2 * 4^5of the best candidates can still leave an answer short. The dense LSM_VECTOR with BINARY quantization: findNeighborsFromVector returns an empty list while another thread commits deletes and inserts near the query, although 3,000 records are live #9396 loop has the same limit.Review cycles
328216de1bkeepcapmax(k, 100_000)could NARROW a first pass withk * oversampleabove it. Fixed inaa13ca39b5: stop when the wider budget is not greater. Multi-index saturation re-run documentedaa13ca39b5rescoreExactlydrops for one reason only. Done in62639746cb62639746cbcommittedForGroups. Done ind3f5f6b332(grownWidening)d3f5f6b332Skipped review suggestions (with rationale)
boolean[]out-params -> result holder" (cycles 1, 4): kept on purpose. This is the exact shapeSQLFunctionVectorNeighbors.searchAndEmituses for vectorNeighbors answers fewer than limit rows while another thread commits deletes: the SQL function skips records the index still returns and does not top up #9368, and the two twins should read alike.oversample == 0before the loop" (cycle 1): that branch shares the candidate selection (filter and overlay exclusion) with the rescored branch. Splitting it out would duplicate that code.STALE_TOP_UP_GROWTH = 4alignment" (cycles 2, 3): the column alignment matches the file's existing field-declaration style.rescoreExactly's single drop reason" (cycles 3, 4): there is no other drop reason today, so there is nothing a test could inject. The Javadoc now states the contract at the place where a second reason would be added.slow/ require a minimum probe count" (cycle 3): the whole class runs in about 1s, which is not slow-lane material. A minimum probe count is a throughput bound that a GC stall on CI would turn red. The unfixed code fails it 3/3 with more than 5,000 probes per run.topKGroupedTopsUpCandidatesWhoseRecordIsGoneandtopKForGroupsTopsUpCandidatesWhoseRecordIsGonereturned[].topKStillAnswersShortWhenTheIndexReallyHoldsFewerandanIndexHoldingFewerThanKStillAnswersWhatItHas.Final state
clean-approval: the last review found nothing to act on. Merge is up to the maintainer.🤖 Generated with Claude Code
Summary by CodeRabbit