Three-Phase Commit (3PC)
What you'll learn: How Three-Phase Commit improves on 2PC by adding a pre-commit phase to reduce coordinator failure blocking, but still can't handle network partitions.
The Problem 3PC Tries to Solve
You've learned that Two-Phase Commit (2PC) has a blocking problem: if the coordinator crashes after participants vote "yes" but before they hear "commit" or "abort," those participants are stuck waiting indefinitely, unable to decide the transaction's fate safely.
Three-Phase Commit adds an extra phase to address this specific blocking scenario.
How 3PC Works
3PC splits the commit phase into two steps:
- Prepare Phase: Just like 2PC — coordinator asks all participants if they can commit
- Pre-Commit Phase (new): If everyone votes "yes," the coordinator sends a "pre-commit" message. Participants acknowledge but don't commit yet. This signals "we've all agreed and the coordinator knows it"
- Commit Phase: Coordinator sends the final "commit" message, and participants commit
The Key Insight
The pre-commit phase creates a state where participants know that everyone agreed and the coordinator is proceeding. If participants don't hear the final commit, they can timeout and safely commit anyway, because they know all other participants reached pre-commit too.
This eliminates the indefinite blocking from coordinator failure mid-commit.
The Fatal Flaw: Network Partitions
While 3PC reduces blocking, it cannot handle network partitions. If the network splits during pre-commit, some nodes might see the message while others don't. Different groups may make conflicting decisions about committing or aborting, violating consistency.
In practice, network partitions happen more often than coordinator crashes, making 3PC's solution incomplete for real-world distributed systems.
Key Takeaway: Three-Phase Commit adds a pre-commit phase to reduce blocking from coordinator failures, but still cannot safely handle network partitions, limiting its practical use in distributed systems.