Skip to content

[tx] Phase-2 commit failure uses reset() instead of rollback(), leaving dangling RIDs on user documents #4940

Closed

Description

@lvca

Severity: MEDIUM

Location: TransactionContext.java:807-812 (commit2ndPhase finally calls reset()) vs rollback():247-295.

On any commit2ndPhase failure the finally calls reset(), which releases locks but skips two things rollback() does: reloading records in modifiedRecordsCache, and resetting the identity of newRecords (the #4562 fix). User-held MutableDocuments created in the failed tx keep an optimistically-assigned RID pointing at a record that was never persisted; re-saving them in the retry treats them as updates of a missing record. The phase-1 failure path correctly uses rollback().

Fix: in the finally, call rollback() (or its record-restoration portion) when !committed.


Filed from an internal engine deep-audit (2026-07). Traced to source; verify against current main before fixing and add a regression test.

Activity

  1. added
    audit
    concurrency
    on Jul 3, 2026
  2. added this to the 26.8.1 milestone on Jul 4, 2026
  3. self-assigned this
    on Jul 6, 2026
  4. added theissue type on Jul 6, 2026
  5. added 4 commits that reference this issue on Jul 6, 2026
  6. lvca commented on Jul 7, 2026

    @lvca
    MemberAuthor

    Fixed in #5061 (merged). commit2ndPhase's failure handling now distinguishes durability regimes instead of calling reset() unconditionally: a failure BEFORE the WAL append rolls back user-held record state exactly like a phase-1 failure (modified records reloaded, created-record identities reset to provisional per #4562, so a retry re-inserts instead of updating a never-persisted RID); a failure AFTER a real append keeps reset() - the transaction is durable, recovery replays it, and the RIDs stay valid - composed with #5053's recovery fence in the same branch. The useWAL=false path always rolls back (nothing durable, nothing to replay). Hardened through three review rounds: the degraded path (rollback itself failing at the dictionary reload) preserves the primary exception AND still resets created-record identities. Red-first verified ('expected: null but was: #1:0' on unfixed code).

  7. added a commit that references this issue on Jul 7, 2026
  8. added a commit that references this issue on Jul 7, 2026
  9. added a commit that references this issue on Jul 8, 2026
  10. added a commit that references this issue on Aug 13, 2026
  11. added 5 commits that reference this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

auditbugconcurrency

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions