Software Design

How Two-Phase Commit Prevents Split Brains

State Diagrams · made in Skemio

State diagram showing Two-Phase Commit starting from an initial state into Preparing, branching via choice to either Committing or Aborting, and ending at a final state.
State diagram showing Two-Phase Commit starting from an initial state into Preparing, branching via choice to either Committing or Aborting, and ending at a final state.

What it shows

  • Prepare phase asks every node to validate and reserve locks.
  • A single failure or timeout aborts the entire transaction.
  • Commit phase is irreversible once unanimous votes are logged.

The takeaway

2PC prioritizes atomicity and consistency at the cost of coordinator lock latency.

More state diagrams