Show TOC Start of Content Area

Process documentation Two-Phase Commit  Locate the document in its SAP Library structure

Purpose

The purpose of the two-phase commit (2PC) protocol is to ensure the atomicity of distributed transactions. These are transactions that work with more than one resource manager, and which must synchronize their branches when they finish their work.

This graphic is explained in the accompanying text

If the transaction works with five resource managers and one of them fails while the others commit, the failed one will not be able to commit later and the atomicity of the transaction is broken. This will also affect the integrity of data since the changes are not saved in all resource managers.

Process Flow

In the 2PC scenario, there is one coordinator branch that sends a request to all other branches of the transaction to prepare to commit. The coordinator is the server node that starts the distributed transaction.

In this first phase, the coordinator must obtain a positive reply from all branches in order to send a message for the transaction commitment. If all branches return a positive reply, the transaction commits (graphic 1). If there is at least one branch that returns a negative reply or unknown status, the system rolls back the whole transaction (graphic 2).

In the second phase the coordinator sends a message to all branches to either commit or rollback. If any of the branches fails to commit, the whole transaction rolls back.

Note

The acknowledgements sent by the resource managers to confirm the execution of the transaction branches do not affect the performance of the system. The performance depends on how fast the preparation and the commitment or rollback of the branches is executed.

This graphic is explained in the accompanying text

Graphic 1: Commit Scenario

 

This graphic is explained in the accompanying text

Graphic 2: Rollback Scenario

 

 

 

End of Content Area