Repository navigation
feat(#6970): share the tx-overlay REMOVE/REPLACE filtering rules across the index read paths - #8741
Conversation
…ss the three index read paths LSMTreeIndex.get(), HashIndex.get() and LSMTreeIndexCursor.getClosestEntryInTx() each re-implemented which disk RIDs a pending transaction removal hides. The rules now live in PendingIndexRemovals; each caller folds the per-key overlay entries through accumulate() and applies the answer to its own result shape. No allocation when the key has no pending removal. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
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. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches📝 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 |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 7 |
🟢 Coverage 100.00% diff coverage · -6.02% coverage variation
Metric Results Coverage variation ✅ -6.02% coverage variation Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (f21a576) 200476 168989 84.29% Head commit (9626016) 233036 (+32560) 182408 (+13419) 78.27% (-6.02%) 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 (#8741) 47 47 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%
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.
ReviewOverall this is a clean, well-scoped refactor. I traced the old logic against
Suggestions (none blocking)
Security and performance: no concerns; no new dependencies, and no extra allocation on the common path. Nice cleanup, and the mutation-check evidence in the description is a good touch. |
…it helper tests, add LSM unique lookup case Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ReviewI read the full diff and compared each call site to the code it replaces. I did not compile or run the tests. This is a behavior-preserving refactor and I found no regressions. Behavior check
Suggestions (non-blocking)
ConventionsThe code follows CLAUDE.md: it reuses existing components, uses |
…veFrom on a widened key, point to rule-3 lookup coverage Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Review: share tx-overlay REMOVE/REPLACE filtering (#6970)Overall: a clean, behavior-preserving refactor. I traced the old inline logic in the three call sites against What I checked
Minor suggestions (non-blocking)
TestsCoverage is good: the helper is tested in isolation with no DB, the point-lookup shapes not reached by Security / performanceNo security concerns (internal read-path logic only). No performance regression expected; the extra allocation is one small holder object only when a removal is actually pending, versus a lazy set/flag before. LGTM once CI is green. |
…in the cursor, test REPLACE after a key-wide removal Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Review of #8741: share tx-overlay REMOVE/REPLACE filtering rules (#6970)I read the diff only. I did not compile the branch or run the tests here. Verdict: no blockers. The refactor looks behavior-preserving. Behavior equivalence (checked against the old code)
Suggestions (non-blocking)
Style (CLAUDE.md)
Nice cleanup overall, and the mutation-check result in the PR description is a good sign for test strength. |
…eKey so the unique early exit has no copy of it Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Review: PendingIndexRemovals refactor (#6970)I compared the old and new logic path by path and found no blockers. Behavior equivalence
Minor suggestions (non-blocking)
The new files follow the repo conventions (license header, AssertJ |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8741 +/- ##
============================================
- Coverage 76.01% 75.99% -0.02%
+ Complexity 3656 3654 -2
============================================
Files 2067 2068 +1
Lines 200476 200466 -10
Branches 42236 42230 -6
============================================
- Hits 152388 152350 -38
- Misses 31529 31560 +31
+ Partials 16559 16556 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #6970
Summary
LSMTreeIndex.get(),HashIndex.get()andLSMTreeIndexCursor.getClosestEntryInTx()each had their own copy of the rules that decide which disk RIDs a pending transaction removal hides from a read. The rules now live in one place, the newcom.arcadedb.index.PendingIndexRemovals. Each caller folds the per-key overlay entries throughPendingIndexRemovals.accumulate(current, entry, unique)and applies the answer to its own result shape:hides(rid)for the point lookups,removeFrom(mergedRIDs)for the range cursor. The rules are:REMOVEwith a RID hides that RID.REMOVEwith no RID, or anyREMOVEon a unique index, hides the whole key.REPLACEwith a non-nulloldRidhidesoldRid, the removalTransactionIndexContext.commit()replays.The class Javadoc names
TransactionIndexContext.commit()/addIndexKeyLockas the code it has to stay in step with, so a new operation shape has one place to re-audit. Rule 2 is also available on its own asPendingIndexRemovals.removesWholeKey(entry, unique). The point lookups call it for their unique-index early exit, so that shortcut does not carry its own copy of the rule.This is a refactor with no behavior change:
accumulatereturnsnulland allocates nothing for a key with no pending removal, the same as the old lazy set/flag. When there is a removal it allocates one small holder plus the RID set, and it skips the set entirely for a key-wide removal.get(): it still returnsEMPTY_CURSORstraight away. The check (removesWholeKey) runs beforeaccumulate, so that path allocates nothing either.limitearly exit inget(): unchanged.Test plan
Issue6927RangeScanTxRemovesTest(the 9 cases from PR fix(#6927): subtract the tx-overlay REMOVE entries from an index range scan #6966), unchanged, greenPendingIndexRemovalsTest(8 cases, no database): each rule tested on the helper itself, including the "no removal = null, no allocation" case,removesWholeKey, and key-wide wins in every order (per-RID or REPLACE after key-wide, and key-wide after per-RID)Issue6970PendingIndexRemovalsTest(5 cases): the point-lookup shapes An index range scan inside a transaction ignores the tx overlay REMOVE entries, returning rows deleted or re-keyed in that same transaction #6927's test does not reach. HASH non-unique per-RID and key-wideremove, LSM non-unique per-RIDremove, and a unique delete on both HASH and LSMhides()to key-wide only turned 5 new tests and 3 An index range scan inside a transaction ignores the tx overlay REMOVE entries, returning rows deleted or re-keyed in that same transaction #6927 tests redmvn -pl engine test -Dtest='com/arcadedb/index/**/*Test,com/arcadedb/database/**/*Test,*Transaction*Test,*Unique*Test' -DexcludedGroups=benchmark,slow,vectoron the final head: 1383 tests, 0 failuresCoverage
Invariant: every index read that merges the transaction overlay hides exactly the disk RIDs that commit's replay will remove, decided by one function.
Sweep:
grep -rn "getIndexKeys(" --include='*.java' . | grep -v /test/LSMTreeIndex.get()(point lookup, LSM)PendingIndexRemovalsHashIndex.get()(point lookup, HASH)PendingIndexRemovalsLSMTreeIndexCursor.getClosestEntryInTx()+fetchNext()(range scan)PendingIndexRemovalsTransactionVectorOverlay/SparseTransactionOverlaygetIndexKeysin a commentTransactionIndexContext.getTxDeletedEntries()(REMOVE/REPLACE -> deleted RID, for the unique check)Known gaps: None
Adversarial pass
This session had no subagent tool, so the independent Phase 1.5 reviewer could not be spawned. The author did the pass instead, which makes it less independent. It re-derived each caller's old behavior against the helper:
limitearly exitoldRidNo findings. The three bot reviews below did the same equivalence trace independently and also found no behavior change.
Review cycles
53c5ce16aeisUnique(), rewrapping a long comment, a DB-free helper test, and an LSM unique lookup case. All applied in171e8f671c171e8f671caccumulate's result must be reassigned,removeFromon a widened key, and a pointer to the rule-3 lookup coverage. All applied in7081c7c7eb7081c7c7ebget(), hoistingisUnique()in the cursor, testing REPLACE after key-wide, and fixing the test count. All applied in27f033610527f0336105false, a cursor coverage pointer, and a test count fix. Applied in9626016427, which no bot has reviewed (max cycles reached)Deferred items
These were skipped. They are optional and the reviewer marked them non-blocking.
PendingIndexRemovalsTestneeds no database and runs in milliseconds, whileIssue6970PendingIndexRemovalsTestdrives the callers through a real transaction.addToorfoldwould make the in-place update a bit more obvious. Optional." Keptaccumulate. The Javadoc says the result must be reassigned, and every caller does so.get()... could be trimmed to a one-liner." Trimmed to one line in cycle 4. The#Nreferences are kept, following the convention used acrossengine/.final var typeis used in a few places." Kept, to match the neighbouringIssue6927RangeScanTxRemovesTest.Final state
max-cycles-reached. All four bot reviews were "no blockers / LGTM once CI is green". The last commit (9626016427, rule 2 shared throughremovesWholeKey) passed the local run but has not been bot-reviewed.🤖 Generated with Claude Code
Summary by CodeRabbit