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.
Trace how services and their databases enlist as participants, vote during preparation, and receive the coordinator’s decision. section 9.1.2
