The protocol
Two phase commit is a blocking agreement protocol run by a coordinator over a set of participants. It guarantees that all participants reach the same decision: commit or abort.
In the prepare phase the coordinator asks every participant to get ready and lock its data. Each participant replies yes only if it can durably commit. In the commit phase the coordinator looks at the votes. If all said yes it tells everyone to commit, otherwise it tells everyone to abort.
The blocking weakness
Between voting yes and hearing the verdict, a participant is in doubt. It holds locks and cannot decide alone. If the coordinator crashes at that moment, participants block until it returns. This is the famous availability cost of two phase commit.
- Strong consistency is the benefit.
- Coordinator failure can freeze progress.
- Held locks reduce throughput under contention.
Three phase commit adds a step to reduce blocking, but it assumes bounded delays that real networks rarely honor.
Key idea
Two phase commit guarantees one shared decision but blocks participants while the coordinator is unreachable.