Transactions Design
Transactions provide atomic multi-operation updates. Single-group transactions commit through the owning Raft log. Cross-group transactions use a two-phase commit coordinator so participating groups record the same decision.
Components
Section titled “Components”TransactionHandlerdispatchesTX_*wire messages.TransactionManagerowns legacy stateful sessions and rebuilds recoverable state from committed entries and snapshots.TransactionExecutorevaluates staged operations against the local registry.TransactionKeyLockManagerandTX_LOCK_KEYprovide transaction-scoped per-key locking.TwoPhaseCoordinatorandTwoPhaseParticipantimplement cross-group prepare/decide flow.ReplicatedTransactionCommandandReplicatedTransactionCodecdefine the durable command format.
Single-group path
Section titled “Single-group path”- The client builds a transaction or batch whose keys resolve to one group.
TX_COMMITis submitted through that group’s Raft write path.- The apply path validates locks and preconditions.
- The result is recorded with idempotency metadata.
- Retries after a dropped response return the recorded result.
Cross-group path
Section titled “Cross-group path”- The coordinator splits the command into per-group slices.
- Each participant group prepares through its own Raft log.
- The coordinator records the final decision on
raft-0. - Participants receive COMMIT or ABORT decisions and acknowledge.
- Recovering participants query the coordinator for the recorded decision.
Invariants
Section titled “Invariants”- A committed single-group transaction applies exactly once.
- Participants never commit without a coordinator decision.
- A lost client response does not cause duplicate apply on retry.
- Transaction-scoped locks are released on terminal outcomes or recovery cleanup.
Failure behavior
Section titled “Failure behavior”Leader failover during single-group commit may return an ambiguous outcome; clients should retry with the same
transaction identity. Coordinator failover recovers durable prepare/decide state from raft-0. Broader crash-window
stress remains tracked in V2_IMPLEMENTATION_GAPS.md; LoomCache does not claim XA semantics.
Verification
Section titled “Verification”Transaction commit/rollback, failover, coordinator durability, cross-group 2PC, idempotent retry, and lock-path tests cover this layer. Operators watch cross-group prepare/decide duration, aborts, recoveries, commit latency, and boundary exceptions.