In 1981, Dale Skeen published a groundbreaking paper designed to fix the fundamental limitation of Two-Phase Commit: The Three-Phase Commit (3PC) Protocol.
Skeen observed that 2PC blocks because cohorts in the PREPARED state cannot
distinguish whether the coordinator died before or after making a commit
decision.
By introducing an intermediate PreCommit phase, 3PC creates a non-blocking
commit protocol for crash-stop failure models.
However, as we will discover, 3PC has a fatal vulnerability in real-world asynchronous networks with network partitions, which is why modern distributed databases use Paxos/Raft instead of 3PC.
1. How Three-Phase Commit Works
3PC splits the commit process into three non-blocking phases:
2. Why 3PC is Non-Blocking Under Crash-Stop
What happens if the Coordinator crashes during 3PC?
In a pure Synchronous / Fail-Stop environment (where servers crash cleanly and network latency is strictly bounded by a known constant ), 3PC completely eliminates the indefinite blocking problem of 2PC!
3. The Fatal Flaw of 3PC: Network Partitions (Split-Brain)
Why does almost no production distributed database (Google Spanner, CockroachDB, PostgreSQL, TiDB) use 3PC today?
Because real-world networks are asynchronous and prone to network partitions.
When a network partition occurs during 3PC, the protocol can cause catastrophic state divergence (Split-Brain):
The Scenario Explained:
- Coordinator sends
CanCommit?to all nodes. All vote YES. - Coordinator sends
PreCommitto Cohort 1, but a network partition drops the packets to Cohorts 2 and 3. - Partition A (Coordinator + Cohort 1): Both are in
PreCommit, so they advance and COMMIT the transaction. - Partition B (Cohorts 2 and 3): They timed out in
CanCommitwithout receivingPreCommit. Following 3PC rules, they elect a new coordinator and ABORT the transaction. - Outcome: The database is now permanently corrupted with inconsistent data on opposite sides of the network.
4. 2PC vs 3PC vs Raft/Paxos: The Architectural Comparison
Why Consensus Replaced 3PC:
Modern distributed transactional databases (CockroachDB, YugabyteDB, Google Spanner) solve atomic commitment by pairing Two-Phase Commit with Raft/Paxos consensus:
- Instead of a single coordinator, the transaction record itself is replicated to a Raft consensus group.
- If the leader dies, Raft elects a new leader within who resumes the 2PC state without blocking or splitting.