Repository navigation
Description
Summary
The rules that decide which RIDs a pending transaction removal hides from a read are now written out three times, nearly verbatim:
engine/src/main/java/com/arcadedb/index/lsm/LSMTreeIndex.java-get()engine/src/main/java/com/arcadedb/index/hash/HashIndex.java-get()engine/src/main/java/com/arcadedb/index/lsm/LSMTreeIndexCursor.java-getClosestEntryInTx()
Each walks the same TransactionIndexContext.getIndexKeys(<indexName>) map for one key and has to reach the same three conclusions:
REMOVEwith a RID - hide that RID.REMOVEwith no RID, or anyREMOVEon a unique index - hide the whole key.REPLACEwith a non-nulloldRid- hideoldRid, becauseTransactionIndexContext.commit()replays exactly that removal.
Why it is worth fixing
PR #6966 is the evidence. It started as a range-scan fix and implemented rules 1-3 in LSMTreeIndexCursor only. Code review then found that LSMTreeIndex.get() was missing rules 2 and 3 independently - a unique-index point lookup returned both the replaced and the replacement RID under a key that holds one, and a key-wide remove(keys) on a non-unique index allocated an empty filter set and hid nothing. HashIndex.get() carried the identical gaps because it is a copy of the same block. Three sites, three separate chances to be wrong, and the two get() sites had been wrong since REPLACE was introduced (25.3.2).
A fourth call site would get the same chance.
Suggested shape
A small static helper that takes the per-key Map<IndexKey, IndexKey> (plus isUnique()) and answers "which RIDs are hidden, and is the whole key hidden", leaving each caller to apply the answer to its own result shape. LSMTreeIndex and HashIndex share no base class carrying an index-specific get(), so the helper cannot be an inherited method.
Constraints:
- These are hot read paths. The helper must not allocate when the visited key has no pending removal - today both the set and the flag are lazily produced, and that has to survive.
- It must stay in step with
TransactionIndexContext.commit()'s replay: if the merge rules inaddIndexKeyLockever produce a new operation shape (for instance aREPLACEwhoseoldRidis null from somewhere other than today's cross-bucket duplicate check atTransactionIndexContext.java:546), the helper is the single place to re-audit. - Refactor only: PR fix(#6927): subtract the tx-overlay REMOVE entries from an index range scan #6966's
Issue6927RangeScanTxRemovesTest(9 cases, unique/non-unique, per-RID/key-wide/REPLACE, both scan directions, raw sub-index andTypeIndex) has to stay green unchanged.
Context
Follow-up to #6927 / PR #6966, raised in code review on that PR. Not a user-visible bug on its own - the three sites agree today.
Activity
feat(#6970): share the tx-overlay REMOVE/REPLACE filtering rules acro…
robfrank commentedon Sep 30, 2026
Done in #8741. The rules that decide which index entries a pending in-transaction removal hides from a read used to be copied in three places: the LSM and HASH point lookups and the LSM range cursor. They now live in one shared class,
PendingIndexRemovals, so a future change to how removals are recorded has one place to update. There is no behavior change. The existing #6927 tests pass unchanged, new tests cover the HASH/LSM lookup paths the old tests did not reach, and a key with no pending removal still allocates nothing. The refactor is complete.❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
feat(#6970): share the tx-overlay REMOVE/REPLACE filtering rules acro…