Skip to content
Latchkey

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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →