← Lessons

quiz vs the machine

Platinum1820

Concurrency

Three Phase Commit

Add a pre commit phase to two phase commit to avoid blocking on coordinator failure.

5 min read · advanced · beat Platinum to climb

Removing the block

Three phase commit, or 3PC, extends two phase commit with an extra round so a single coordinator crash does not leave participants blocked. It inserts a pre commit phase between voting and committing.

The three phases

  • Can commit the coordinator asks if everyone can commit. Participants reply yes or no but do not yet lock in.
  • Pre commit if all said yes, the coordinator sends pre commit. Participants acknowledge and now know the decision will be commit.
  • Do commit the coordinator tells everyone to commit.

The pre commit phase makes the outcome recoverable. If the coordinator dies, a participant that reached pre commit knows the group agreed to commit and can drive the decision forward with the others.

The catch

3PC is non blocking only under a synchronous network with reliable failure detection.

  • It assumes bounded message delay and detectable crashes.
  • Under network partitions it can still make inconsistent decisions, which is why production systems prefer consensus protocols like Paxos or Raft.

Key idea

Three phase commit adds a pre commit round so participants can finish a decision without the coordinator, but it only stays non blocking under synchronous, partition free assumptions.

Check yourself

Answer to earn rating on the learn ladder.

1. What phase does 3PC add over 2PC?

2. What problem does the pre commit phase solve?

3. When can 3PC still make inconsistent decisions?