Practice this topic in a realistic system design interview
Three-Phase Commit (3PC) is an atomic commit protocol designed to reduce the blocking problem in Two-Phase Commit.
In 2PC, a participant that has voted yes is stuck if the coordinator disappears before delivering the final decision. It cannot safely commit or abort on its own, so it waits, often while holding locks. 3PC inserts an extra phase between "everyone voted yes" and "commit now" so that participants have enough information to make progress without the coordinator.
3PC is rarely used in production. Its non-blocking behavior depends on strong assumptions: bounded message delays, reliable failure detection, fail-stop processes, and no network partitions. Real networks usually do not satisfy those assumptions. The protocol is still worth understanding because it makes the relationship between atomic commit, blocking, and timing assumptions explicit.
In 2PC, the dangerous state is prepared, also called in doubt.
A prepared participant knows only part of the story.
| What It Knows | What It Does Not Know |
|---|---|
| It voted yes | Whether every other participant voted yes |
| It can commit if told to commit | Whether the coordinator decided commit or abort |
| It must follow the final decision | Whether another participant already received that decision |
If participants knew that everyone had voted yes before the coordinator failed, commit would be safe. If they knew that not everyone had voted yes, abort would be safe.
3PC adds a phase to communicate exactly that missing information.