consensus
Three Phase Commit (3PC)
Non-blocking extension of 2PC: adds pre-commit phase to avoid coordinator-failure blocking.
phaseIDLE
transactions0
Phase 1: can-commit
Phase 2: pre-commit
Phase 3: do-commit
COORDINATOR
○
P1
idle
✓ ok
○
P2
idle
✓ ok
○
P3
idle
✓ ok
Click participants to toggle failure
// transaction log
No transactions yet
How It Works
- Phase 1: CAN-COMMIT? (voting round)
- Phase 2: PRE-COMMIT (prepare to commit)
- Phase 3: DO-COMMIT (finalize)
- If coordinator fails after pre-commit, participants can recover
vs 2PC
- + Non-blocking on coordinator failure
- + Participants can timeout and decide
- − Higher latency (3 round trips)
- − More complex, rarely used in practice