Two-Phase Commit
A protocol for committing one transaction across multiple databases atomically, at the cost of blocking if the coordinator dies.
Two-phase commit is a protocol for making a single transaction succeed or fail atomically across multiple independent databases or services. It splits the commit into two rounds: in the prepare phase, a coordinator asks every participant to get ready and durably record that it can commit, and each replies yes or no; only if every participant says yes does the coordinator send a commit phase telling everyone to finalize. A single no, or a timeout, aborts the whole transaction everywhere.
The guarantee it buys is real: no participant commits unless all of them can, which is exactly the atomicity half of ACID extended across a network boundary that a single database's own transaction log can't reach. The cost is what makes it unpopular in practice. Once a participant votes yes in the prepare phase, it surrenders the right to decide for itself: it must hold its locks open and abide by whatever the coordinator rules — and if the coordinator crashes between the two phases, every participant is stuck holding those locks indefinitely, unable to unilaterally commit or abort. This is the protocol's well-known blocking problem, and it's why 2PC shows up more in textbooks and legacy enterprise middleware (XA transactions) than in systems built for high availability.
Modern distributed systems mostly route around it rather than fixing it: Event Sourcing and the outbox pattern achieve cross-service consistency through eventual, retryable delivery instead of a blocking vote, and systems that do need synchronous cross-node agreement typically reach for a Consensus Algorithm like Raft, which tolerates a failed coordinator without freezing.
See also4
ACID
The four guarantees a transactional database makes so concurrent, interrupted work never leaves data half-done.
Data & Content9 connections
Consensus Algorithm
A protocol that gets a majority of unreliable, independent nodes to agree on one value, surviving any minority failing.
Data & Content4 connections
Event Sourcing
Storing every change that ever happened, instead of only the current state, so the current state becomes a derived view.
Data & Content5 connections
Eventual Consistency
A guarantee that replicas converge given no further updates, without guaranteeing when.
Networks & Distribution16 connections
Related1
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from5
- ACIDData & Content
The four guarantees a transactional database makes so concurrent, interrupted work never leaves data half-done.
- Consensus AlgorithmData & Content
A protocol that gets a majority of unreliable, independent nodes to agree on one value, surviving any minority failing.
- Database ShardingData & Content
Splitting one dataset across multiple databases by key, trading a single point of scale for cross-shard complexity.
- Leader ElectionData & Content
The process a distributed system uses to pick one node to coordinate, and to notice and replace it when it dies.
- Pessimistic LockingData & Content
Blocking every other writer up front for the duration of a transaction, betting that collisions are common enough to prevent rather than clean up.