Skip to content

Fix #8982 #8983 #8984: lost update on multi-page docs, double hash index write, non-retryable concurrent delete - #8989

Merged
lvca merged 10 commits into
mainfrom
fix/8982-8983-8984
Oct 3, 2026
Merged

lvca merged 10 commits into
mainfrom
fix/8982-8983-8984

Conversation

@lvca

@lvca lvca commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #8982, #8983, #8984.

Tests: Issue8982LostUpdateLargeDocumentTest, Issue8983HashIndexKeyChangeTest, Issue8984ConcurrentDeleteRetryTest; Issue6950RecordImageGuardTest updated to the new contract.

Summary by CodeRabbit

  • Bug Fixes
    • Improved conflict detection for concurrent deletes and updates, including large, multi-page records.
    • Improved index consistency when keys change within a transaction and prevented duplicate index updates during commit.
  • Tests
    • Added coverage for concurrent retries, large-record updates, and index behavior across SQL and Java API operations.

…x write per key change, retryable concurrent delete
@lvca lvca added this to the 26.10.1 milestone Oct 3, 2026
@lvca lvca self-assigned this Oct 3, 2026
@mergify

mergify Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

@codacy-production

codacy-production Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity

Metric Results
Complexity 5

View in Codacy

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.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1555e696-cb5b-4d0c-8946-a6961e3e487f
📥 Commits

Reviewing files that changed from the base of the PR and between 9b3fd33 and 003ffbe.

📒 Files selected for processing (3)
  • engine/src/main/java/com/arcadedb/database/LocalDatabase.java
  • engine/src/main/java/com/arcadedb/database/TransactionIndexContext.java
  • engine/src/test/java/com/arcadedb/index/Issue8983HashIndexKeyChangeTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • engine/src/main/java/com/arcadedb/database/LocalDatabase.java

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The changes detect stale multi-page records, convert selected concurrent deletes into retryable conflicts, and change index handling during commit. Tests cover record updates, concurrent deletes, and indexed-key changes.

Changes

Multi-page Record Conflict Detection

Layer / File(s) Summary
Compare multi-page record images
engine/src/main/java/com/arcadedb/engine/LocalBucket.java, engine/src/test/java/com/arcadedb/engine/Issue6950RecordImageGuardTest.java, engine/src/test/java/com/arcadedb/engine/Issue8982LostUpdateLargeDocumentTest.java
The record guard assembles multi-page records and compares them with the read image. It rethrows concurrent-modification errors during assembly. Tests cover unchanged and changed records, stale updates, and concurrent increments.

Concurrent Delete Conflicts

Layer / File(s) Summary
Classify concurrent deletes
engine/src/main/java/com/arcadedb/database/ImmutableDocument.java, engine/src/main/java/com/arcadedb/database/LocalDatabase.java, engine/src/test/java/com/arcadedb/database/Issue8984ConcurrentDeleteRetryTest.java
The delete path converts a not-found error to ConcurrentModificationException when the record was read in the current transaction and was not already deleted there. Tests cover document and vertex delete races and retryable exceptions.

Index Update Consistency

Layer / File(s) Summary
Handle index changes during commit
engine/src/main/java/com/arcadedb/database/LocalDatabase.java, engine/src/main/java/com/arcadedb/database/TransactionContext.java, engine/src/main/java/com/arcadedb/database/TransactionIndexContext.java, engine/src/main/java/com/arcadedb/index/sparsevector/LSMSparseVectorIndex.java, engine/src/test/java/com/arcadedb/index/Issue8983HashIndexKeyChangeTest.java
The first commit phase skips index discovery for deferred updates. Queued unique-key changes preserve an earlier add in the described replacement case. Comments describe index queuing and deferral of other writes during an in-flight commit. Tests cover key changes, duplicate keys, and index entries.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant TransactionA
  participant LocalDatabase
  participant ImmutableDocument
  TransactionA->>LocalDatabase: Delete record
  LocalDatabase->>ImmutableDocument: Check transaction read marker
  ImmutableDocument-->>LocalDatabase: Return loaded-in-transaction match
  LocalDatabase-->>TransactionA: Return retryable conflict for matching missing record
Loading

Suggested reviewers: robfrank

Merge Risk: ⚪ Minimal · up to 003ff

The supplied evidence identifies no issue requiring correction before merge. Mergeability remains subject to normal test checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 003ff

The changes improve conflict detection and preserve index entries during key swaps. However, deferred commits can serialize a property changed after the last save while indexing and validating its earlier value. This creates a material consistency concern within transactions that already have write access; no new external access or privilege expansion was established.

Retained concerns

  • Medium · security · inferred: Deferred commit can persist a different indexed property value from the one queued and validated at save. The transaction stores the mutable record, so save with key A followed by mutation to key B without another save serializes B at commit, while the changed flush path replays only A. If B is already occupied in a unique index, validation still checks A rather than the persisted B. This threatens indexed identity and uniqueness guarantees for callers with existing transactional write authority. The record/index divergence is supported by the head flow; its application-specific security consequences are inferred, and the prior HASH uniqueness bypass should not be attributed to this PR.
Security review details

Security Blast Radius

  • inferred — The identified mismatch is reachable by a caller already able to update mutable documents and commit transactions. Its scope is indexed records writable through that database transaction path. No unauthenticated route, cross-tenant authority expansion, or infrastructure privilege gain was established.

Security Findings and Attack Paths

  • inferred — A write-authorized caller can save an available indexed key, then mutate the same document to another value without saving again. Commit serializes the latter value while validating and replaying the earlier key. This can undermine applications relying on indexed identity or uniqueness; no application-specific authorization bypass was verified.

Trust Boundaries and Controls

  • observed — The changed addIndexKeyLock logic transforms existing transaction-local operations without introducing a new caller authority. The unordered lane still rejects unique indexes, and normal commit validation remains active for queued ADD and REPLACE operations.

Resilience and Maintainability Implications

  • inferred — Existing rollback journaling and post-WAL failure fencing provide containment for interrupted transitions, with recovery replay after durable failures. They do not detect or repair a normally committed disagreement between serialized properties and queued keys. Crash behavior for this exact swap path was not directly tested in the inspected evidence.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed #8982 requires a stale READ_COMMITTED update to a multi-page document to fail with a retryable ConcurrentModificationException. The reviewed implementation compares the complete record chain with the …
Out of Scope Changes check ✅ Passed The commit-time index change and concurrent-delete handling support the current PR description's #8983 and #8984 objectives. The unique-key swap handling and tests address an index consistency case ex…
Title check ✅ Passed The title clearly summarizes the three primary fixes: multi-page document lost updates, duplicate hash-index writes, and retryable concurrent deletes. It is specific, though somewhat long.
Description check ✅ Passed The description explains the changes, links the related issues, and lists the tests. It does not include the template’s explicit section headings or checklist, and it does not state the motivation sep…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of #8989 (fixes #8982, #8983, #8984)

Solid, well-targeted fixes with a regression test per issue. I read the three engine changes against their call sites and found nothing blocking. Notes below, mostly minor.

#8983 (skip re-index at commit flush) - looks correct

I verified the claim in the new comment: the in-tx branch of updateRecord (LocalDatabase ~1603-1650) already runs indexer.updateDocument(...) and queues the change (with the #4935 snapshot and #8066 undo), so the commit-time updateRecordNoLock call was indeed the second write. The only other caller of updateRecordNoLock inside the commit is the edge-append rebase (TransactionContext ~1406), which passes an edge segment (not a Document), so it is unaffected.

  • Stale comment: TransactionContext ~2233 still says the updateRecordNoLock above "can register [an index replay conclusion], since a deferred UPDATE indexes here rather than at save() time". After this PR that is no longer true. Worth updating.
  • Gating on getStatus() != COMMIT_1ST_PHASE is implicit coupling to the transaction state machine. Fine given the comment, but any future non-deferred caller running during COMMIT_1ST_PHASE would silently skip indexing.

#8982 (multi-page hasRecordChangedSinceRead) - correct, with a cost

  • Assembling the chain and comparing with size() + isSameRegionAs is the right fix, since the off-page fingerprint is taken from the already-newer head page and cannot see this.
  • Performance: every update of a multi-page record now reads and allocates the full record a second time (including the validation/retry loop in loadMultiPageRecord). For the counter-on-a-large-document pattern this roughly doubles read work per write. Acceptable for correctness, but worth a line in the PR description. If it shows up in profiles, comparing the head chunk bytes first and assembling only when they are equal would short-circuit the common "changed" case.
  • The new catch (ConcurrentModificationException e) { throw e; } before catch (Exception e) is needed and correct, and the Javadoc is updated to match. One Javadoc line (the off-page fingerprint one) now exceeds the usual wrap width, cosmetic only.

#8984 (retryable concurrent delete) - looks correct

Tests

  • Good coverage: stale read-modify-write at 30k/70k/300k, a concurrent-counter test, unique/non-unique x B-tree/hash index cases, a stale-entry-after-delete case, and Issue6950RecordImageGuardTest updated to the new contract.
  • concurrentCountersOnMultiPageDocumentLoseNoIncrement runs 4 threads x 100 retried transactions on a 70 KB record with retries = 100000. If it takes noticeable time, tag it @Tag("slow") per CLAUDE.md; a smaller retry cap would also turn a livelock into a failure instead of a hang.
  • Issue8984ConcurrentDeleteRetryTest injects the race deterministically via a BeforeRecordDeleteListener, avoiding timing flakiness. No wall-clock assertions, consistent with CLAUDE.md.

Style / CLAUDE.md

No new dependencies, no debug System.out, imports used instead of FQNs, assertj style used.

No blocking issues. I suggest fixing the stale TransactionContext comment before merge.

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of #8989 (fixes #8982, #8983, #8984)

I read the diff and the surrounding code in TransactionContext, LocalDatabase and LocalBucket. I did not build or run the tests. Overall the three fixes are well targeted and the new tests describe the failures clearly. No blockers from me, only the points below.

#8982: multi-page lost update (LocalBucket.hasRecordChangedSinceRead)

  • The reasoning in the comment is right. The off-page fingerprint is taken from the page that was just pinned, so it cannot see a commit that landed between the read and the pin. Comparing the assembled chain against readImage closes that gap.
  • Performance: the first update of a multi-page record in a transaction now walks the whole chain twice. loadMultiPageRecord does it for the new check, and offPageContentFingerprint does it again right after in addUpdatedRecord. The chain is then read a third time when it is serialized at commit. This is probably acceptable, since it only affects records over a page and only the first update per transaction. Still, it would be worth a micro-measurement on a 300 KB document, and a short comment saying the cost is intentional. If the fingerprint could be derived from the same walk, that would remove one pass.
  • loadMultiPageRecord can also throw BrokenChunkChainException and DatabaseOperationException. The generic catch (Exception) swallows both and returns false, so a broken chain falls back to the old behaviour (no guard). That matches the existing "never fail a write because the re-read failed" policy. But this is the one place where the guard silently stops guarding, so the FINE log may deserve a higher level for the chain-specific exceptions.
  • The catch (ConcurrentModificationException) { throw e; } is needed because the generic catch follows it. The Javadoc is updated to say so, which is good.

#8983: double index write (LocalDatabase.updateRecordNoLock)

  • The fix is correct for the path it targets. Every record in updatedRecords has already gone through updateRecord() and had its index changes queued, so skipping the diff in the commit-time flush is right.
  • Design nit: the guard depends on getTransaction().getStatus() != COMMIT_1ST_PHASE. That is implicit coupling between a public updateRecordNoLock and the commit sequence. Any future caller that reaches it during COMMIT_1ST_PHASE and does need indexing (for example another commit-time rebase) would silently skip index maintenance. The method Javadoc already warns about this kind of bypass. An explicit parameter or a private overload used only by the commit1stPhase flush would be safer, and it would make the contract visible at the call site. If you keep the status check, I'd add a line to that Javadoc.
  • Behavioural change to be aware of: indexes now reflect the last save() call. A property changed on a MutableDocument after its last save() but before commit used to be indexed by the commit-time flush, and the body was written with it. Now the body and the index could disagree. That is arguably a caller bug, but it is a change.
  • Test gap: there is no test for the same record updated twice in one transaction, which is the [tx] Updating the same indexed record twice in one transaction permanently corrupts the index #4935 snapshot path. There is also none for a combined case such as a multi-page document with an indexed property.

#8984: retryable concurrent delete

Tests and style

  • All new tests are in the engine module and follow the AssertJ style. The Thread, ExecutorService and AtomicReference usage is fine, and there are no wall-clock assertions.
  • concurrentCountersOnMultiPageDocumentLoseNoIncrement runs 4 threads with 100 transactions each, with up to 1000 retries, on 70 KB documents. It may be slow or flaky under CI load. Consider @Tag("slow") or fewer iterations.
  • The comment in TransactionContext.commit1stPhase (around line 156) was edited into a single very long line. Please re-wrap it to match the rest of the block.
  • The new comments lean on issue numbers and long narrative. That matches the surrounding code, so I wouldn't change it, but a couple could be shorter.

Nice work on the root-cause analysis. The only item I'd try to settle before merge is the implicit COMMIT_1ST_PHASE coupling in #8983.

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of PR 8989

The three fixes are well scoped, the comments explain the reasoning, and the regression tests hit each failure shape. I read the diff and the surrounding code but have not run the tests. A few points are worth a look before merge.

1. Issue 8983: a mutation after save() is no longer indexed (possible regression, no test)

updatedRecords holds the live MutableDocument reference, and the commit-time flush serializes whatever state the object has at commit. Before this change the flush re-indexed against that final state. Now only the index changes queued by updateRecord() at save() time are applied. Consider:

final MutableDocument d = ...modify();
d.set("k", 1).save();   // index change queued for k=1
d.set("k", 2);          // no second save()
database.commit();      // body written with k=2, index replays k=1

The record body and the index can now disagree, where previously the flush corrected the index (with the double-write bug). Mutating after save() without saving again is questionable usage. Still, please either add a test that pins the intended behavior or state in the PR that it is deliberately unsupported. All the tests added here save after the last mutation.

The status check is also a broad filter: updateRecordNoLock now skips indexing for any Document while in COMMIT_1ST_PHASE. The Javadoc warns future callers, and today only the deferred flush runs there (the edge-segment rebase passes a non-Document). An explicit flag or overload would be sturdier than keying off the transaction status, but this is not a blocker.

2. Stale comments after the 8983 fix

  • LSMSparseVectorIndex.java around line 967 (7933) still says "An UPDATE indexes at commit time, not at save() time - commit1stPhase() drains its deferred writes through updateRecordNoLock, which re-runs DocumentIndexer and lands right here". That is no longer true after this PR. Please re-check whether the replayBuffer(tx) branch it justifies is still reachable, and fix or remove the comment either way.
  • A grep for 7933, 7934 and "indexes here rather than at save" would catch any other wording that still describes commit-time indexing.

3. Issue 8982: performance on the write path

hasRecordChangedSinceRead now calls loadMultiPageRecord on every update of a multi-page record. That assembles the whole record (potentially MBs) into a new Binary and walks the full chain with its retry and trace machinery, and the commit path reads it again. For read-modify-write workloads on large documents, like the counter pattern in the new test, that doubles read amplification and adds garbage. Possible mitigations:

  • Compare chunk by chunk against readImage while walking the chain, with no assembled copy and an early exit on the first mismatch.
  • Skip the comparison when the chain is provably unchanged since the read (for example, via page versions), if that information is reachable here.

If reusing the hardened chain walk is the point, that is reasonable. A Javadoc line about the cost, and a quick benchmark with a 70 KB document, would help.

Smaller notes:

  • The "Never throws" contract is now "throws only CME". The only caller today is checkRecordIsStillTheOneRead, which tolerates it.
  • A BrokenChunkChainException from the assembly falls into the generic catch and returns false, so a broken chain silently means no guard. That matches the existing "do not fail a write on unreadable pages" policy, and a FINE log exists.

4. Issue 8984: behavior change for callers

  • ConcurrentModificationException now replaces RecordNotFoundException / VertexNotFoundException for records read in the same transaction. Code that catches not-found around deleteRecord for idempotent deletes, and layers that map not-found to 404, will see a retryable conflict in this race. That seems right, but it deserves a release-notes line.
  • The rid.equals(e.getRID()) guard correctly avoids reclassifying a missing edge or endpoint vertex. Please add a negative test: a stale reference or a missing neighbour must still surface the non-retryable not-found (the 6572 / 6586 contract). The new tests only cover the positive side.
  • Wrapping the delete branches in a try re-indents about 40 lines. That is functionally neutral but makes the diff noisy.

5. Tests

  • Style follows CLAUDE.md (AssertJ assertThat(...), no System.out, no wall-clock assertions). The 8984 race tests are deterministic.
  • concurrentCountersOnMultiPageDocumentLoseNoIncrement runs 4 threads x 100 transactions on a 70 KB document with up to 1000 retries. Under heavy contention on slow CI it could take a while or exhaust retries. Consider lowering the contention or adding @Tag("slow") if it takes more than a few seconds locally.
  • Please add the missing cases from points 1 and 4.

Security

No concerns. The change is internal to engine concurrency control and adds no new inputs.

Summary

Nothing blocking from the code I read. Point 1 (index and body divergence after an unsaved mutation) needs a test or an explicit decision, point 3 deserves a look at the cost on large documents, and the stale comments in point 2 are best fixed in this PR.

@lvca

lvca commented Oct 3, 2026

Copy link
Copy Markdown
Member Author

Review round notes: mutating a MutableDocument after its last save() and before commit is deliberately unsupported for index maintenance (the index follows the last save()); every write path in the engine and the SQL/Cypher executors saves after the last mutation. The #6572/#6586 not-found contract for stale references is pinned by Issue6572DanglingVertexReferenceTest and Issue6586MissingVertexDiagnosisTest, which still pass. Release-notes line for #8984 to be added with the docs update.

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of #8989

Overall this is a well-scoped, well-explained set of three fixes with targeted regression tests. I found no blocking issues; a few points below are worth a look.

What looks good

Points to consider

  1. Performance of A concurrent update of a document larger than one page is silently overwritten under READ_COMMITTED: the transaction that read the older version commits and the other transaction's change is lost, with no ConcurrentModificationException #8982 (LocalBucket.hasRecordChangedSinceRead): every update of a multi-page record now walks and copies the full chain at addUpdatedRecord time, in addition to the existing off-page fingerprint walk at commit. For a 300 KB document that is an extra full read plus an allocation per update. This is probably an acceptable price for correctness, but please confirm with a quick measurement (e.g. repeated UPDATE on a large doc before/after), since CLAUDE.md asks us to be GC-conscious on the write path. If it matters, a cheaper option is to compare chunk by chunk and stop at the first difference, without assembling a new Binary.
  2. Mutable records in A SQL DELETE that loses a race with a concurrent delete of the same record fails with RecordNotFoundException (VertexNotFoundException for a vertex, advising CHECK DATABASE FIX), which transaction(..., retries) does not retry, while UPDATE in the same race gets a retryable conflict #8984: asConcurrentDeleteIfReadHere only converts for record instanceof ImmutableDocument. A MutableDocument obtained through modify() and then passed to deleteRecord after a concurrent delete will still surface as the non-retryable RecordNotFoundException. If that shape is reachable, it is worth handling; if it is deliberately out of scope, a one-line note in the Javadoc would help.
  3. Test coverage for A SQL DELETE that loses a race with a concurrent delete of the same record fails with RecordNotFoundException (VertexNotFoundException for a vertex, advising CHECK DATABASE FIX), which transaction(..., retries) does not retry, while UPDATE in the same race gets a retryable conflict #8984: the two race tests go through SQL DELETE FROM. theConflictIsRetryableWhenSurfaced covers the Java API for a plain document only. A Java API case for a vertex (the VertexNotFoundException path named in the issue) and one for an edge would cover the graphEngine.deleteVertex/deleteEdge branches of the new try/catch.
  4. Test robustness: Issue8984ConcurrentDeleteRetryTest calls otherThread.submit(...).get() from inside a BeforeRecordDeleteListener with no timeout. If the other transaction ever blocks on something the listener's thread holds, the test hangs instead of failing. get(30, TimeUnit.SECONDS) (or a @Timeout sized as a hang detector, per CLAUDE.md) would make a regression diagnosable. The same applies to the .get() calls in Issue8982LostUpdateLargeDocumentTest.
  5. Test coverage for HASH indexes apply a key change twice at commit: UNIQUE_HASH lets an UPDATE take a key another record holds, and NOTUNIQUE_HASH keeps a stale entry that later returns a record with a different key #8983: SQL UPDATE and the Java API on UNIQUE_HASH are covered. A rollback-after-conflict case asserting no leaked index entry, and a Java API case on an LSM UNIQUE index, would be nice-to-haves.
  6. Style nit: the reflowed hasRecordChangedSinceRead Javadoc line ("off-page fingerprint ... exactly as before. A freed or deleted slot also") is now well past the wrap width used by the rest of the block.

Security

No concerns: no new input surface, no new dependencies.

Verdict

Looks good to merge once the performance impact of point 1 is confirmed acceptable. The rest are suggestions.

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of #8989

Overall this is a well-scoped set of fixes. Each fix is small, each root cause is explained in the comments, and each has a dedicated regression test. I found no blocking issues. The points below are mostly about cost and edge cases.

#8982: multi-page lost update (LocalBucket.hasRecordChangedSinceRead)

  • Correctness: assembling the whole chain and comparing it with the read image is the right approach. The off-page fingerprint is taken from the page that is already pinned, so it could never see this case. Falling back to false on non-CME exceptions is consistent with the existing "the commit-time check is still behind it" policy. Re-throwing ConcurrentModificationException before the generic catch is correct.
  • Performance: for every update of a multi-page record this now does a full chain assembly (an allocation of the record size plus the revalidation machinery of loadMultiPageRecord) on top of the existing offPageContentFingerprint walk, and then the fingerprint walk again at commit. For multi-MB documents under bulk update that roughly doubles the read cost. It is the price of correctness here and probably acceptable. A cheap prefix compare of the head chunk against readImage before assembling would let the "changed" outcome exit early. The "unchanged" outcome still needs the full read. It is worth a short comment or a follow-up issue so the cost is a conscious choice.
  • Nit: the Javadoc line at LocalBucket.java:1100 is now well over the surrounding wrap width.

#8983: no re-indexing in COMMIT_1ST_PHASE (updateRecordNoLock)

  • The diagnosis is sound: updateRecord() already queues the index diff, and the commit flush re-diffed against the frozen committed buffer outside the queue. Skipping indexing there is the minimal fix. I checked the callers of updateRecordNoLock. The in-transaction flush (TransactionContext:2214) is the only one that runs in that phase with a Document. The edge segment write at TransactionContext:1406 is not a Document. The async path and the implicit-transaction path run while the status is BEGUN, so they still index.
  • The guard is a status check inside a method that is public on DatabaseInternal. The Javadoc warning helps, but this is an implicit contract. A future caller in that phase will silently skip indexing, with no error. Consider a dedicated flush method or an explicit flag rather than inferring the intent from the transaction status.
  • Tests cover UNIQUE/NOTUNIQUE and the HASH variants, repeated updates in one transaction, delete after key change, and a multi-page document, which is thorough.

#8984: retryable concurrent delete

Tests

  • The new tests follow the project style (AssertJ, no raw wall-clock assertions, @Timeout used as a hang detector).
  • concurrentCountersOnMultiPageDocumentLoseNoIncrement runs 4 threads x 100 retried transactions on a 70KB record, with up to 1000 retries each. Under heavy contention on a slow CI runner it could take several seconds. Please check its elapsed time and tag it @Tag("slow") if it is noticeable. Only the last worker failure is kept in failure[0].
  • staleReadModifyWriteIsRefusedForPlainAndMultiPageDocuments: if an assertion fails mid-loop, thread A's open transaction is never rolled back. It only matters for failure diagnostics.
  • The Issue6950RecordImageGuardTest update correctly flips the old "not reported as changed" contract.

Security / compatibility

No new security surface. The conversion to a NeedRetryException changes client-visible behaviour for concurrent deletes, which is the intended fix. Callers that previously caught RecordNotFoundException around a concurrent delete will now see a CME, so the release notes should mention it.

Nothing here blocks a merge once CI is green.

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of #8989

I read the diff and the surrounding code. I did not build or run the tests. This PR has already had several reviews, so I only repeat the points I think matter and add one that is new. I found nothing blocking.

What looks right

Points to consider

  1. Undocumented behaviour change in TransactionIndexContext.addIndexKeyLock. The new branch (ADD B queued, then REMOVE A on the same unique key, rewritten as a REPLACE with oldRid set) is not mentioned in the PR description, which lists three fixes and none of them says this. It is correct as far as I can trace, and recordsSwappingUniqueKeysInOneTransactionKeepEveryEntry covers it. It is index-queue logic that other writers reach, so a line in the PR description would help the next reader. A test for the reverse order (REMOVE A, then ADD B) would also pin that the older path still behaves the same.
  2. A concurrent update of a document larger than one page is silently overwritten under READ_COMMITTED: the transaction that read the older version commits and the other transaction's change is lost, with no ConcurrentModificationException #8982 cost. A multi-page update now assembles the chain here, walks it again in offPageContentFingerprint, and reads it a third time at commit. That is acceptable since it only affects records larger than a page, once per transaction. A short comment saying the cost is deliberate would stop someone "optimizing" the check away later. An early exit on a prefix mismatch of the head chunk would make the "changed" outcome cheaper.
  3. Mutation after save() and before commit. The index now follows the last save(), not the final object state. The author has said this is deliberately unsupported. It would be worth a sentence in the updateRecordNoLock Javadoc as well, since that is where the next person will look.
  4. Implicit coupling. Gating index maintenance on getStatus() != COMMIT_1ST_PHASE ties updateRecordNoLock to the transaction state machine. The Javadoc warns about it, which is enough for now. Passing an explicit flag from the flush would be sturdier if more callers appear.
  5. Test style. Tests follow the project conventions (assertThat, @Timeout as a hang detector, no wall-clock assertions). The new tests use a single-thread executor and a BeforeRecordDeleteListener to force the interleaving, which keeps them deterministic. Nice.

Verdict: good to merge once CI is green, with the TransactionIndexContext description note and the oldRid check in point 1 as the only things I would look at first.

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of #8989 (fixes #8982, #8983, #8984)

I read the diff and the surrounding code. I did not build or run the tests, so my comments are about design and risk.

Overall this is a well-scoped set of fixes. The comments explain the reasoning, and each issue has a regression test that exercises the real race. A few points below, most important first.

1. #8983: the index now follows the last save(), not the committed state (behavior change)

updateRecordNoLock now skips indexing when the status is COMMIT_1ST_PHASE. The Javadoc says so: a property changed after save() and before commit is not re-indexed.

  • Before this change the commit-time flush re-diffed the record, so the pattern below left the index consistent with the record.
  • After this change the record is written with k=2 but the index keeps k=1, which is silent index/record divergence.
doc.set("k", 1).save();
doc.set("k", 2);   // no second save
commit();
  • updatedRecords holds the same MutableDocument instance, so the later set is flushed even without a save().
  • It is a niche pattern, but it is a correctness regression rather than only a performance one.
  • Please consider either adding a test that pins this contract, or detecting the divergence at flush time (for example by comparing the record's current state with the last-indexed snapshot from [tx] Updating the same indexed record twice in one transaction permanently corrupts the index #4935, and re-queueing only when they differ).
  • A status-based check (getStatus() != COMMIT_1ST_PHASE) is also an implicit coupling. A new caller in that phase, such as the edge-segment rebase at TransactionContext.java:1406, silently gets no indexing. The Javadoc covers this, but an explicit parameter would be safer than inferring intent from the phase.

2. #8982: cost of assembling the whole chain on every update of a multi-page record

hasRecordChangedSinceRead now calls loadMultiPageRecord for every update of a multi-page record.

  • This allocates and copies the full record (300 KB in your test) per save(), on top of the record already read.
  • The cost is not new in kind, since the commit path already walks chains. It is still extra GC and I/O on a write hot path, for example for repeated updates of one large document in a transaction.
  • If the head chunk carries a length or a version, a cheap early exit may be possible before assembling.
  • Otherwise a note in the Javadoc that this is deliberate would help the next reader.
  • Related: catch (ConcurrentModificationException e) { throw e; } before catch (Exception) is correct. Other failures while assembling (BrokenChunkChainException, RecordNotFoundException) are swallowed as "unchanged", which matches the "never fail a write" intent. This is worth a test with a deliberately broken chain.

3. #8984: coverage gap for MutableDocument

asConcurrentDeleteIfReadHere only upgrades when record instanceof ImmutableDocument.

  • A record that was loaded, then modify()'d (a MutableDocument/MutableVertex), and then deleted after a concurrent delete still gets the non-retryable RecordNotFoundException.
  • That is a plausible read-modify-delete pattern. Is it intentionally out of scope? If so, a short comment would help. If not, the source image or begin sequence would need to be carried across modify().
  • The catch (RecordNotFoundException) now wraps graphEngine.deleteEdge and deleteVertex. The rid.equals(e.getRID()) guard correctly prevents misclassifying a missing neighbour or edge. The tests only cover the target record itself, so a test where a connected edge or neighbour is missing, asserting it stays non-retryable, would lock that guard in.

4. Unique-index key swap in addIndexKeyLock

The ADD-then-REMOVE-on-same-key handling looks right to me, and recordsSwappingUniqueKeysInOneTransactionKeepEveryEntry covers the main case.

  • v.oldRid = entry.oldRid != null ? entry.oldRid : rid drops the REMOVE's rid if the existing entry is already a REPLACE carrying a different oldRid. On a unique index this should not happen, but an assertion or comment would document it.
  • The addKeptByRemove flag plus reassigning v makes this method harder to follow. A brief comment on why the unique-check is skipped (it already ran when the ADD was queued) would help.

5. Minor / style

  • The LSMSparseVectorIndex change is comment-only and the new text is accurate. Keeping the deferral, as you did, is right.
  • The new tests use the assertThat(...) style and @Timeout as a hang detector, as per the conventions. Nothing asserts on wall-clock time. Good.
  • In the 8984 race tests the listener blocks on otherThread.submit(...).get() while the outer transaction is open. It passed in your run, but a note on why that cannot deadlock on a file lock would reassure.

Verdict

Nothing here blocks the merge on correctness of the three headline fixes. I'd like point 1 (the index vs. record divergence after a post-save() mutation) addressed or explicitly pinned by a test before merge. Points 2 and 3 are worth a short reply or comment.

🤖 Generated with Claude Code

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of #8989 (fixes #8982, #8983, #8984)

I read the main-source diff in full and skimmed the tests. I did not build or run anything. The three fixes are targeted and the Javadoc explains the reasoning. Findings are below, most important first.

1. #8983: index can disagree with the stored record after a post-save() mutation (worth a decision or a test)

LocalDatabase.updateRecordNoLock now skips index maintenance in COMMIT_1ST_PHASE. This relies on updateRecord() having queued every index change at save time. The deferred write in updatedRecords holds the same mutable object, though. The commit flush serializes whatever the object holds at commit time, not at save() time.

Scenario:

doc.set("k", 1).save();   // index change for k=1 queued
doc.set("k", 2);          // no save()
commit();                 // body is written with k=2, index still says k=1

Before this PR the commit-time re-index diffed against the committed buffer and picked up k=2, apart from the double-write bug. After it, the stored record and the index silently disagree. The new Javadoc admits this ("a property changed after it and before commit is not re-indexed"), but I'd treat it as a behavior regression, not a documentation item.

Options:

  • Snapshot the record at save() time. This costs allocations, so it may be unattractive.
  • Make the flush index only when the record is dirty relative to the last indexed snapshot (getLastIndexedSnapshot).
  • Accept it explicitly. In that case add a test that pins the contract, so the choice is deliberate.

At the moment none of the three new tests covers this shape.

2. #8983: the unique-swap branch in TransactionIndexContext.addIndexKeyLock

The branch looks correct for the swap case (ADD B queued, then REMOVE A on the same key). Some details need confirming:

  • It skips the unique check with addKeptByRemove, on the grounds that "the check already ran when the ADD was queued". That holds for entry.operation == ADD/REPLACE on the same index. The cross-sub-index check (TypeIndex.getIndexesByKeys) also ran at ADD time, so I think it is fine. A short note on that would help.
  • v.oldRid = entry.oldRid != null ? entry.oldRid : rid assumes the REMOVE's rid is the committed holder. If A's REMOVE can come from a record that was itself added in this tx (not committed), oldRid would point at a non-committed RID. I don't think DocumentIndexer can produce that sequence, but it is not covered by recordsSwappingUniqueKeysInOneTransactionKeepEveryEntry. A 3-record rotation test (A->B->C->A keys) would exercise the REPLACE-then-REMOVE path as well.
  • new IndexKey(true, ...) hard-codes unique = true. That is fine inside the index.isUnique() branch, but index.isUnique() would read more clearly and stay consistent with the other constructor call.

3. #8982: cost on the hot write path

hasRecordChangedSinceRead now assembles the full chain through loadMultiPageRecord for every first update of a multi-page record in a tx. offPageContentFingerprint then walks the same chain again right after, in addUpdatedRecord. The correctness argument holds and the extra cost only hits large records. Still, given the "performance first" guidance, consider:

  • Reusing the assembled chain, or fusing the two walks.
  • Noting the double traversal in a comment, so the next change doesn't add a third.

Also, loadMultiPageRecord has a retry loop driven by TX_RETRIES. Please confirm it cannot sleep or back off while the caller holds the page pin and read lock, since this path is now reached from updateRecord() under executeInReadLock.

The catch (ConcurrentModificationException e) { throw e; } ahead of catch (Exception e) is correct but easy to lose in a refactor. The comment is good. A dedicated test that a chain moving mid-assembly surfaces as a CME (not a swallowed false) would pin it, if the existing test doesn't already.

4. #8984: retryable delete

asConcurrentDeleteIfReadHere is well scoped:

  • The RID match prevents misclassifying a different missing record, for example an endpoint of an edge.
  • The isDeletedInTransaction exclusion is there.
  • Stale references stay non-retryable.

Minor points:

  • Wrapping the whole if/else if/else in a try re-indents about 40 lines, which makes the diff noisy. Extracting the body into a helper would shrink it, but this is purely cosmetic.
  • wasLoadedInTransaction is package-private and depends on readInTransaction, so it relies on the Vertex modify() silently reloads a stale read under READ_COMMITTED, losing read-modify-write updates (Java API) #8610 bookkeeping being set on every load path (SQL DELETE ... WHERE scans, lookupByRID, index lookups). The tests cover SQL DELETE for document and vertex plus lookupByRID. If some iterator path doesn't set readInTransaction, the result is the old non-retryable error, so it fails safe. Worth a one-line test for an index-driven lookup (the tests already have a unique index, so this may be covered).

5. Tests and style

  • The three new test classes use the repo's AssertJ style and a @Timeout as a hang detector, as the guidelines ask. There is no wall-clock assertion.
  • Issue8984ConcurrentDeleteRetryTest drives the race deterministically through a BeforeRecordDeleteListener, which is good. It leaks nothing, since the listener is unregistered in finally.
  • Comments: several new comments are multi-line and reference issue numbers heavily. The repo already does this in these files, so I'm not asking for changes, but the CLAUDE.md guidance prefers short WHY-only comments.
  • Please also run the connected suites before merge, not just the new tests. At minimum: the existing index tests (unique, hash, LSM vector/sparse-vector deferral), Issue6950*, the [tx] Updating the same indexed record twice in one transaction permanently corrupts the index #4935 multi-update tests, and the server/HA-raft tests that go through commit1stPhase.

Summary

The fixes for #8982 and #8984 look sound. The main open question is item 1, where #8983 trades a double-write for a silent index/record mismatch on post-save() mutations. I'd resolve that or lock it in with a test before merging. Items 2 and 3 are smaller follow-ups.

@codacy-production

codacy-production Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity

Metric Results
Complexity 5

View in Codacy

🟢 Coverage 82.50% diff coverage · -5.86% coverage variation

Metric Results
Coverage variation ✅ -5.86% coverage variation
Diff coverage ✅ 82.50% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (cecb369) 208214 176490 84.76%
Head commit (003ffbe) 240847 (+32633) 190041 (+13551) 78.91% (-5.86%)

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 (#8989) 40 33 82.50%

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.

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of #8989

I read the diff and the surrounding code. I did not run the tests. The three fixes are well scoped and the root-cause analysis in the comments is solid. Nothing here blocks the merge. A few points are worth a look first.

#8982 (multi-page lost update) - LocalBucket.hasRecordChangedSinceRead

  • Write-path cost. Every update of a multi-page record now assembles the whole chain and byte-compares it, once per record taken for update. For 300 KB documents that is an extra full-chain read in every read-modify-write. The correctness gain justifies it, but please say so in the javadoc. A cheaper pre-check could also help, for example comparing the head chunk and the chain length before assembling.
  • Allocation. loadMultiPageRecord allocates a fresh Binary and a trace array per call. That is fine for correctness, but it adds GC pressure on a hot path.
  • Exception handling. The new catch (ConcurrentModificationException e) { throw e; } is correct, and the javadoc now says "Throws only...". BrokenChunkChainException from the assembly still falls into catch (Exception) and returns false. This is fail-open and consistent with the existing contract, but a corrupt chain would let the lost update through silently. That is probably acceptable, and the commit-time check still sits behind it.

#8983 (double hash index write) - LocalDatabase.updateRecordNoLock

  • Phase-based skip. Skipping indexing based on getStatus() != COMMIT_1ST_PHASE is a global rule for every caller of updateRecordNoLock, not a per-caller one. I checked the callers: the deferred flush, the edge-segment rebase (not indexed), async update (status BEGUN) and the Raft/Server delegates. All are fine today. The new javadoc warning helps, but a dedicated private method for the flush path, or an explicit parameter, would be sturdier than a status check.
  • Behavior change. As the javadoc admits, a property changed after the last save() and before commit is now written to the bucket but not re-indexed. Previously the commit-time flush indexed the final buffer. A regression test pinning this behavior, in either direction, would stop it being changed by accident.
  • Stale comments. The TransactionContext comment for !hasChanges() and the LSMSparseVectorIndex comment were rewritten to say what no longer happens. Both now read as history rather than as the reason the code is shaped this way. Consider trimming them to the current invariant.

Unique-key swap fix - TransactionIndexContext.addIndexKeyLock

  • The ADD-then-REMOVE-of-another-record logic looks right: the ADD is kept as a REPLACE that carries the committed holder as oldRid. The entry.oldRid != null ? entry.oldRid : rid fallback relies on a unique key having only one committed holder, and the comment says so.
  • addKeptByRemove skips the unique check on the assumption that it already ran when the ADD was queued. That holds, but it is a subtle invariant. Please add a test where the REMOVE comes from a record that is not the committed holder, to confirm the unique check still catches real conflicts. recordsSwappingUniqueKeysInOneTransactionKeepEveryEntry only covers the happy swap.
  • The reverse order (REMOVE queued before ADD) already worked. Please confirm the test exercises both orders, since the fix is order-dependent.

#8984 (retryable concurrent delete)

  • Coverage gap. asConcurrentDeleteIfReadHere only converts for ImmutableDocument. A MutableDocument or MutableVertex that this transaction loaded (for example vertex.modify(), then delete()) still gets the non-retryable RecordNotFoundException. SQL DELETE goes through immutables, so the reported case is fixed. The Java API path with a modified record is not. Either extend it, or note the limit in the javadoc.
  • Narrowing. Wrapping the whole delete block in try/catch (RecordNotFoundException) is safe because of the rid.equals(e.getRID()) check. A not-found for a different record, such as an edge or a neighbouring vertex, keeps its original verdict. Good.
  • The re-indent of the big block makes the diff noisy. It is unavoidable, but it could have been a small private method to keep the diff small.

Tests

Style

  • The long javadocs and block comments are heavier than the CLAUDE.md "short comments" guideline. The project already follows this style in these files, so this is not a blocker.
  • No new dependencies and no security concerns.

Overall this looks good to merge once the points above are weighed, mainly the mutable-record gap in #8984 and a test for the not-the-holder REMOVE case.

@claude

claude Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review of PR 8989

I read the diff and the surrounding code in LocalBucket, TransactionContext and TransactionIndexContext. I did not run the tests. The three fixes are well targeted and each has a regression test. One behavior change needs a decision before merge.

Main concern: the index can now disagree with the stored record (#8983)

updateRecordNoLock no longer indexes in COMMIT_1ST_PHASE, so the index follows the last save(). The record bytes are still serialized at commit time, because the deferred write keeps the property overlay. In indexFollowsTheLastSaveNotALaterUnsavedMutation this means:

d.set("k", 1).save();
d.set("k", 2);   // never saved again

The record is persisted with k=2 while the index holds k=1. A query by k=2 misses the record, and a query by k=1 returns a record that no longer matches. Before this PR the flush re-indexed, so the final state was consistent apart from the double write.

The PR documents this and pins it with a test. Pinning it means that test would have to be rewritten by a future fix, so the inconsistency is locked in. d.save(); d.set(...); commit is not an exotic pattern, for example when a property is set after save() in a helper or a listener. Some options:

  • Snapshot the serialized image or property overlay at save() time, so the commit writes exactly what was indexed.
  • Re-run the index diff at flush time, but only through the transaction index queue and never directly. This keeps the old behavior without the double write.
  • If neither is acceptable, state the limitation in the release notes. I would not call it a pure bug fix without that.

Smaller points

  1. Cost of the A concurrent update of a document larger than one page is silently overwritten under READ_COMMITTED: the transaction that read the older version commits and the other transaction's change is lost, with no ConcurrentModificationException #8982 fix. hasRecordChangedSinceRead now assembles the whole chain through loadMultiPageRecord on every update of a multi-page record. That is a full read, plus a Binary allocation of the record size, per update. The commit-time offPageContentFingerprint then walks the tail again. This looks acceptable for correctness, but multi-page counter or sequence documents will be slower on this path. A cheap early exit would help: compare the head chunk and the total size first, and assemble only when they match. If you have a microbenchmark number, it would be good to put in the PR.
  2. Swallowed exceptions. loadMultiPageRecord can also raise BrokenChunkChainException, and the generic catch (Exception) turns that into false ("unchanged", logged at FINE). So a broken or mid-publication chain silently disables the lost-update guard. This was already the contract for this method ("never throws"), but the Javadoc now says it throws only the CME, so please say the other exceptions fail open.
  3. addIndexKeyLock swap handling. The new branch builds a REPLACE with oldRid = entry.oldRid != null ? entry.oldRid : rid. This assumes the rid of the incoming REMOVE is the committed holder of the key. If a REMOVE arrives for a record that is not the committed holder, it would queue a bogus oldRid for removal. I could not find a way to reach that case, and the unique-check skip is sound for the reasons in the comment. A short test for ADD B then REMOVE A where A was never the committed holder would settle it. The existing swap test covers only the happy path of a full permutation.
  4. asConcurrentDeleteIfReadHere. The rid.equals(e.getRID()) guard correctly keeps unrelated not-found errors, for example from edge cleanup, non-retryable. The documented limitation for a modify()d record is fine. theConflictIsRetryableWhenSurfaced could also assert the cause is the original RecordNotFoundException, since the code passes it through.
  5. Tests.
    • concurrentCountersOnMultiPageDocumentLoseNoIncrement runs 4 threads x 100 transactions on a 70 KB record with up to 1000 retries each. It has no @Tag("slow") and no @Timeout, unlike the other new classes. Please add a hang-detector @Timeout, and the slow tag if it takes more than a few seconds.
    • It also captures failures via a shared Throwable[] written from several threads. It works, but an AtomicReference is cleaner.
    • The tests in Issue8983HashIndexKeyChangeTest loop over index kinds and create a type per iteration. That is fine, but as(kind) is missing on some assertions, so a failure inside a database.transaction lambda will not say which kind failed.
  6. Style. The inline comments are long, multi-line blocks that mostly explain the issue history. CLAUDE.md asks for at most one short line explaining a non-obvious WHY. The existing code in these files already leans verbose, so this is a nit. The edited comments in LSMSparseVectorIndex and TransactionContext mostly restate history ("before 8983...") and could be shortened.

Positives

  • The guard getStatus() != COMMIT_1ST_PHASE is narrow, and I checked the callers. The edge-segment rebase at TransactionContext:1406 passes a MutableEdgeSegment, which is not a Document, so it is unaffected. The async path runs in BEGUN.
  • Reusing loadMultiPageRecord, with its chain-trace validation, is the right way to get a consistent read.
  • The existing Issue6950RecordImageGuardTest was updated to the new contract instead of being deleted.

Overall: good fixes with solid tests. I would resolve the "index follows last save" decision before merging, and add the @Timeout on the counters test.

🤖 Generated with Claude Code

tae898 added a commit to humemai/arcadedb-embedded-python that referenced this pull request Oct 3, 2026
Luca's review note on ArcadeData#8989: changing a record after its
last save() and before the commit is unsupported, since indexes follow the
last save(). Checked through the bindings on the current engine: in one
transaction, set k=1, save, set k=2 (not saved again) commits k=1, and an
index on k agrees, so the later change is simply not written. The record
docs now say so beside the existing note on saving once.


Claude-Session: https://claude.ai/code/session_01Lj5isEaoaGCeaZe5nNoWX4

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.55%. Comparing base (cecb369) to head (003ffbe).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...main/java/com/arcadedb/database/LocalDatabase.java 74.07% 5 Missing and 2 partials ⚠️
...com/arcadedb/database/TransactionIndexContext.java 71.42% 0 Missing and 2 partials ⚠️
...src/main/java/com/arcadedb/engine/LocalBucket.java 60.00% 2 Missing ⚠️
.../java/com/arcadedb/database/ImmutableDocument.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8989      +/-   ##
============================================
+ Coverage     76.54%   76.55%   +0.01%     
- Complexity     3852     3860       +8     
============================================
  Files          2109     2109              
  Lines        208214   208247      +33     
  Branches      43960    43969       +9     
============================================
+ Hits         159377   159431      +54     
+ Misses        31763    31739      -24     
- Partials      17074    17077       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tae898

tae898 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Verified 003ffbe6e7 against 5e44bc7ab3, the build the three issues were filed on, with their reproductions, on Temurin 25 with -XX:+UseCompactObjectHeaders and on Temurin 21, same results on both:

5e44bc7ab3 003ffbe6e7
#8982 two concurrent increments of a 70,000-byte document A commits, B's increment is lost (n = 1, 2 committed) A gets ConcurrentModificationException (n = 1, 1 committed), as at 30,000 bytes
#8983 UNIQUE_HASH: change k from 1 to 2 while another record holds 2 committed, two records with k = 2 DuplicatedKeyException, as UNIQUE
#8983 NOTUNIQUE_HASH: change, delete, insert into the reused RID, then WHERE k = 1 finds the new record (k = 5) []
#8983 hash index entries after one record changes k 2 1
#8984 SQL DELETE FROM Doc WHERE key = 1 losing the race, transaction(..., 3) RecordNotFoundException after 1 attempt committed after 2 attempts
#8984 SQL DELETE FROM Vtx WHERE key = 1 VertexNotFoundException after 1 attempt committed after 2 attempts
#8984 Cypher MATCH (x:Vtx {key: 1}) DELETE x committed after 1 attempt, 0 rows CommandExecutionException after 1 attempt

The last row is a regression on the head: the Cypher form, which already completed, now fails and is not retried. Its cause chain is CommandExecutionException: Error executing Cypher command <- ConcurrentModificationException: Record #3:0 was deleted by a concurrent transaction after it was read in this transaction. Please retry the operation <- VertexNotFoundException. The retryable exception is wrapped by the catch in OpenCypherQueryEngine (the same lines on the head), which rethrows CommandExecutionException, CommandParsingException, and SecurityException and wraps everything else, so transaction(..., 3) sees an exception that is not a NeedRetryException and stops. Rethrowing NeedRetryException there as well, or keeping the 0-row outcome for a Cypher DELETE, would let the Cypher form complete as the issue's expected section asks. Thanks!

@lvca
lvca merged commit 3d67d5c into main Oct 3, 2026
@lvca
lvca deleted the fix/8982-8983-8984 branch October 3, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants