Two-Phase Commit
Two-phase commit (2PC) is the atomic cross-node transaction commit protocol: the coordinator first asks all participants whether to commit, then decides commit or abort.
Purpose
To achieve distributed transaction atomicity and understand its blocking and coordinator single-point problems.
Mechanism
Phase one (prepare): the coordinator sends prepare; participants write WAL and reply yes/no. Phase two (commit/abort): commit if all yes, otherwise abort. If the coordinator crashes, participants block (uncertain).
Use cases
- Distributed transaction design
- Cross-node atomic commit
- XA protocol