liveBook · Manning

Prepare phase

As explained in Microservices Patterns, Second Edition

The first phase of two-phase commit in which participants make changes durable, retain required locks, and vote whether they can commit.

In two-phase commit (2PC), participants first try to make their transaction changes durable. They vote yes if ready to commit or no if they must roll back, while retaining any required locks. The transaction coordinator uses the collected votes to decide what happens in the commit phase. section 9.1.2

Figure 9.1 A hypothetical implementation of XA/2PC in a microservice architecture. The services register as participants with the Transaction Coordinator. They enlist their databases in the distributed transaction. The Transaction Coordinator commits the transaction in two phases. In the prepare phases, participants vote on whether they can commit. In the commit phase, the transaction coordinator instructs all participants to either commit or roll back based on the collected votes.
microservices 2pc

Trace how services and their databases enlist as participants, vote during preparation, and receive the coordinator’s decision. section 9.1.2

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines durability attempts, votes, and lock retention, without detailing their implementation.
Examples
Uses a hypothetical XA setup in which services enlist databases and vote through a transaction coordinator.
What you can do after
Understand how participants signal readiness before a coordinator directs commit or rollback.
How it connects
Connects two-phase commit, transaction coordinators, participants, and the commit phase.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.