← Lessons

quiz vs the machine

Platinum1850

Databases

The Distributed Transaction Coordinator

A coordinator drives two phase commit so a transaction spanning multiple databases commits everywhere or nowhere.

6 min read · advanced · beat Platinum to climb

The Problem

When one transaction touches several databases or services, each can independently succeed or fail. To keep atomicity across all of them, a distributed transaction coordinator orchestrates a protocol so every participant reaches the same outcome.

Two Phase Commit

The standard protocol is two phase commit, or 2PC.

  • Prepare phase: the coordinator asks every participant to prepare. Each does its work, writes it durably, and replies yes if it can commit or no if it cannot. After voting yes a participant must be able to commit even after a crash.
  • Commit phase: if all voted yes, the coordinator tells everyone to commit. If any voted no, it tells everyone to abort. Participants apply the final decision and acknowledge.

The Blocking Weakness

If the coordinator crashes after participants voted yes but before sending the decision, those participants are stuck in doubt, holding locks and unable to decide alone. This blocking is the central weakness of 2PC. Protocols like three phase commit or consensus based approaches reduce it.

Why It Is Costly

2PC adds extra round trips, durable logging at each participant, and held locks across the network, so distributed transactions are far slower than local ones. Many systems avoid them by redesigning toward local transactions or eventual consistency.

Key idea

A distributed transaction coordinator runs two phase commit, gathering prepare votes then broadcasting commit or abort, achieving cross system atomicity but risking blocking if the coordinator fails mid protocol.

Check yourself

Answer to earn rating on the learn ladder.

1. What happens in the prepare phase of two phase commit?

2. What is the central weakness of two phase commit?

3. Why are distributed transactions slower than local ones?