liveBook · Manning

Two-phase commit

Two-phase commit is a distributed transaction protocol that prepares participating systems and then coordinates their collective commitment or abortion.

How 4 Manning books explain it

Think Distributed Systems

A distributed transaction commit protocol that coordinates commitment in two phases among participating processes.

How it is used
Coordinates unanimous commit or abort decisions across resource managers in distributed transactions.
How deep it goes
Explains roles, phases, persistent logs, recovery actions, and failure blocking, while stopping short of implementation code.
Examples
Uses coordinator and resource-manager message flows, persistent log records, recovery actions, and a coordinator-failure scenario.
What you can do after
Evaluate atomic commit behavior and diagnose why coordinator failure can block participants.

Read how Think Distributed Systems explains two-phase commit →

PostgreSQL Mistakes and How to Avoid Them

Two-phase commit is a distributed transaction protocol in which participants first prepare to commit and then commit or abort based on a coordinator decision.

How it is used
Coordinates application-level atomicity when one transaction spans multiple PostgreSQL database nodes.
How deep it goes
Defines the prepare-and-decision protocol and operational hazards, but does not provide a complete implementation procedure.
Examples
Uses alpha and beta account updates, PostgreSQL account fixtures, and a lost-money versus unexpected-gift scenario.
What you can do after
Evaluate cross-node atomicity failures and judge when prepared transactions’ locking and recovery costs outweigh their benefits.

Read how PostgreSQL Mistakes and How to Avoid Them explains two-phase commit →

Kafka for Architects

Two-phase commit is a distributed transaction protocol in which a coordinator first prepares all participants and then directs them to commit or abort as a group.

How it is used
Coordinates atomic outcomes across independent systems when distributed operations must either all succeed or all fail.
How deep it goes
Defines prepare, commit, and abort steps, then stops at Kafka’s lack of current 2PC support and the outbox workaround.
Examples
Uses a profile database update paired with a Kafka notification to expose dual-write inconsistency.
What you can do after
Evaluate when transactional outbox is preferable to direct cross-system writes involving Kafka.

Read how Kafka for Architects explains two-phase commit →

Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

Two-phase commit is a distributed transaction protocol that first obtains participant decisions and then instructs all participants to commit if every participant agrees.

How it is used
Explains why horizontally scaling relational databases becomes difficult when transactional guarantees require coordination among nodes.
How deep it goes
Traces a simplified two-node protocol from query request through unanimous decision and final commit, then stops at scaling overhead.
Examples
Uses a two-node INSERT, UPDATE, or DELETE transaction coordinated through participant checks and a final commit.
What you can do after
Evaluate the coordination cost that transactional guarantees impose when adding nodes to a relational database cluster.

Read how Amazon Web Services in Action, Third Edition: An in-depth guide to AWS explains two-phase commit →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.