Why two-phase commit blocks

yes-vote + unknown decision -> blocked

Two-phase commit distributes the work but centralises the decision, so the coordinator's death suspends every participant that already voted yes.

Two-phase commit looks like a transaction across machines, but its prepare phase makes every participant commit to an outcome it cannot choose. A participant that votes yes writes its redo record and holds its locks, then waits for a decision only the coordinator holds. If that coordinator fails, the waiting participants keep their locks, and every row they touched stays unavailable until someone recovers the decision.

Two-phase commit runs in two rounds. The coordinator sends prepare to every participant. Each one runs its local transaction, writes its redo record to its write-ahead log, takes locks on the affected rows, and replies yes or no. Only when every reply is yes does the coordinator write commit to its own log and send commit to all participants. Any no sends abort instead. Each participant then applies the decision and releases its locks, so the locks are held from the prepare reply until the decision arrives.

The abstraction hides a dependency. After a yes vote, a participant can act on neither outcome alone. Committing is unsafe if another participant voted no. Aborting is unsafe if the coordinator already decided commit and told someone else. A timeout cannot separate a dead coordinator from a slow one, so waiting and timing out both fail. The one specific failure: the coordinator crashes after it has logged commit and told one participant, but before the other hears. The first participant has committed, the second is still waiting with its rows locked, and only the restarted coordinator can finish the job. The decision exists on one machine, which is safe but not available.

Keep a transaction inside one partition whenever the schema allows it, using a shard key or document model that co-locates its writes. If it must span partitions, replicate the coordinator's decision and write it durably before any participant hears it. Never let a participant that voted yes time out into abort or commit on its own; it waits for the decision or for recovery. Treat phase-one locks as the scarce resource they are: budget each transaction's latency as the slowest prepare plus a round trip, and count the rows those locks cover as its blast radius. Restart a failed coordinator rather than killing the transaction it was running, because killing it can leave one side committed and the other not.

orders of magnitude
Lock hold time
until the decision arrives

Locks taken at prepare stay held until the coordinator's decision reaches the participant, so waiting time is lock time.

Coordinator restart
seconds

A restarted coordinator reads its log and resumes, but participants wait on it for that whole interval.

Retry load
proportional to pending participants

The coordinator keeps retrying each participant that has not acknowledged the decision, so retries grow with the number still waiting.

Yes-vote cost
redo record and locks

A participant pays its durable write and lock acquisition before the coordinator has decided anything.

Decision copies
one, in the coordinator's log

The commit decision survives a crash on disk, but no other machine holds a readable copy.

field note

The naive design lets each participant time out and decide alone. That fails because a node that voted yes has already written its redo record and holds its locks. If it aborts on its own, another participant may have committed, leaving half a transaction. If it waits forever, every row it touched stays locked.

The wall is that a timeout cannot separate a dead coordinator from a slow one, so no participant has a safe local rule. Spanner's answer was to run two-phase commit over Paxos groups, so the commit decision is replicated and survives the coordinator's own failure. A participant no longer waits on one machine's disk.

The lesson is that two-phase commit distributes the work and centralises the decision. Until the decision itself is replicated, a coordinator failure suspends every participant that voted yes, by design rather than by bug. The fix belongs in where the decision lives, not in the timeout values.