The Two Phases
Two phase commit coordinates an atomic transaction across several nodes. In the prepare phase the coordinator asks every participant to vote. A participant that votes yes must promise it can commit and holds its locks. In the commit phase the coordinator, once all voted yes, tells everyone to commit; if any voted no it tells everyone to abort.
Where It Breaks
The protocol is correct when nothing fails, but failures expose a weakness.
- If the coordinator crashes after a participant voted yes but before sending the decision, the participant is stuck. It cannot unilaterally commit or abort, because the outcome may already be decided elsewhere.
- The participant holds its locks while it waits, blocking other transactions.
This is the blocking problem: two phase commit can stall the whole group on a single coordinator failure.
Mitigations
- Participants can ask each other about the decision, but if all uncertain participants are blocked the group still waits.
- A persistent transaction log lets a recovered coordinator resume the decision rather than lose it.
- Three phase commit and consensus based commit reduce blocking by adding rounds or replicating the decision, at higher cost.
Key idea
Two phase commit is atomic but blocking, a coordinator crash after a yes vote can leave participants holding locks with no safe way to decide alone.