Skip to content

Leader silently loses a committed write when replication times out after dispatch (phantom commit + origin-skip) #4790

Closed

Description

@ruispereira

Affected version: 26.6.1
Component: RaftReplicatedDatabase.commit + ArcadeStateMachine.applyTxEntry + RaftGroupCommitter.submitAndWait
Severity: CRITICAL

Summary

The leader applies its own transactions in a local "Phase 2" (commit2ndPhase)
and, to avoid double-applying, applyTxEntry skips the apply for entries
whose context was marked originatedLocally == true. But the local marker is set
at startTransaction for the whole lifecycle, independent of whether Phase 2
actually ran. If replication is dispatched to Ratis and then the wait times out
(tryCancel() fails because already dispatched → QuorumNotReachedException),
commit() rolls back and throws without running Phase 2 — yet Ratis later
reaches quorum and the entry is applied on all followers, while the leader's own
applyTransaction skips it (origin-skip).

Code

RaftReplicatedDatabase.java:316-332 (rollback+throw on the dispatched-timeout path),
RaftGroupCommitter.java:158-168 (QuorumNotReachedException after dispatch),
ArcadeStateMachine.java:243-255 (marks originatedLocally), :576-579 (skips apply when local).

Impact

The transaction is durably committed in the Raft log and applied on every
follower, but never applied on the leader — silent permanent divergence / a
lost write on the leader, with no WALVersionGapException and no step-down.
Worst class of bug for a consensus system.

Suggested fix

Condition the origin-skip on Phase 2 having actually completed (track a per-entry
"applied locally" marker keyed by Raft log index / client call-id, set only after
commit2ndPhase succeeds); on the dispatched-but-timed-out path, block on local
apply or force Phase 2 / step down rather than rollback-and-skip.

Activity

  1. added this to the 26.7.1 milestone on Jun 29, 2026
  2. self-assigned this
    on Jun 29, 2026
  3. added theissue type on Jun 29, 2026
  4. added a commit that references this issue on Jun 29, 2026
  5. lvca commented on Jun 29, 2026

    @lvca
    Member

    Fixed

  6. added a commit that references this issue on Jul 21, 2026
  7. added 2 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

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions