Two-phase commit
Definition
Two-phase commit (2PC) is an atomic commitment protocol in which a coordinator asks all participants to prepare (and vote), then tells all of them to commit if every vote was yes, or to abort otherwise.
In practice
It gives all-or-nothing semantics across databases or between a database and a broker, which is why it appears in XA transactions and inside distributed databases. Once a participant votes yes it must be able to commit even after a crash, so it holds locks and writes its vote durably.
Participants that have voted yes are stuck, holding locks, until they hear the coordinator's decision, so a coordinator failure can block them. 2PC also ties the availability and latency of every participant together, and many brokers and cloud databases do not support it. Across services, sagas or a transactional outbox are usually preferred.
Example
An order service and a ledger database both vote yes in the prepare phase; the coordinator crashes before sending commit, and both keep the affected rows locked until it recovers 2 minutes later.