Two-phase commit (2PC) is an atomic commit protocol for distributed transactions. It coordinates multiple resource managers so every local transaction commits together or aborts together. Without failures, it provides safety and liveness; with coordinator failure, it preserves safety but may block. section 6.3 section 6.4
The system has exactly one transaction coordinator (TC) and at least two resource managers (RMs). A client performs reads and writes through the RMs, then asks the TC to commit or abort the global transaction. section 6.3.1
2PC proceeds in two phases:
- Prepare: the TC persistently logs Prepare and asks every RM to vote. An RM may persistently record Vote-to-Commit, or persistently record Abort and abort locally. section 6.3.1
- Commit: if every RM votes to commit, the TC persistently logs Commit and instructs all RMs to commit. Any Abort vote or timeout makes the TC log Abort and instruct all RMs to abort. section 6.3.1
- The preparation asymmetry is deliberate: an RM can unilaterally abort, but it cannot unilaterally commit. section 6.3.1
Coordinator failure after a vote
Suppose all RMs vote to commit, the TC tells RM1 to commit, and then the TC fails. RM2 cannot safely choose commit or abort because it does not know whether another RM has already committed, so it remains blocked until the TC is repaired. section 6.3.2
Figure 6.6 2PC protocol execution
Use the protocol execution figure to trace the coordinator, participants, messages, persistent logs, and two decision phases. section 6.3.1



