Cohesive Systems logoCOHESIVE SYSTEMS

Two-Phase Commit

Two-Phase Commit is a coordination protocol for atomic commit across multiple participants.

It attempts to make several resource managers act like one commitment boundary. A coordinator first asks participants to prepare. If every participant votes to commit, the coordinator records and sends the commit decision. If any participant votes to abort or fails before prepare succeeds, the coordinator aborts.

Semantics

Two-phase commit provides atomic agreement about commit or abort for the participants covered by the protocol. It is a realization mechanism for a distributed transaction boundary, not a business guarantee by itself.

The protocol does not eliminate the need to define isolation, durability, recovery behavior, participant membership, timeout meaning, idempotency, or what external observers may see while the protocol is in progress.

Costs and Failure Modes

Two-phase commit is coordination-heavy. It adds synchronous dependency between participants, increases latency, and can reduce availability when participants or the coordinator are unreachable.

Classic two-phase commit can block: a prepared participant may be unable to unilaterally decide commit or abort if it loses contact with the coordinator. Recovery requires durable logs and careful replay of coordinator and participant decisions.

Alternatives

When a single distributed transaction boundary is unavailable or too costly, systems often use weak isolation patterns such as transactional outbox, sagas, compensation, idempotent retry, escrow, reservations, reconciliation, or CRDT-compatible updates.

These alternatives do not provide the same semantics as two-phase commit. They replace one atomic boundary with explicit process, recovery, and invariant-preservation rules.

External References

Related concepts: ACID, isolation, coordination, concurrency control, persistence, recovery, durable execution, business transactions, weak isolation patterns.