What Is Two-Phase Commit?
Two-phase commit is a distributed protocol where a coordinator first asks every participant to prepare and vote on whether it can commit, then in a second phase tells them all to commit or all to abort based on the votes. It guarantees that the participants reach the same outcome. The trade-off is that participants must hold locks while waiting, and a coordinator failure can leave them blocked.
Why it matters
Two-phase commit provides atomicity across separate databases or services, but its blocking nature and coordinator dependency make it heavy. Many systems prefer sagas or eventual consistency to avoid that cost.
Related guides
What Is a Distributed Transaction?A distributed transaction spans multiple databases or services and must either commit everywhere or roll back…
What Is the Saga Pattern?The saga pattern manages a long-running business process across services as a sequence of local transactions,…
What Is a Transaction Isolation Level?An isolation level sets how much one transaction can see of others in progress, trading consistency guarantee…