Two-phase commit concepts

Every global transaction has a coordinator and one or more participants, defined as follows:
  • The coordinator directs the resolution of the global transaction. It decides whether the global transaction must be committed or stopped.
    The two-phase commit protocol always assigns the role of coordinator to the current database server. The role of coordinator cannot change during a single transaction. In the sample transaction in When the two-phase commit protocol is used, the coordinator is italy. If you change the first line in this example to the following statement, the two-phase commit protocol assigns the role of coordinator to france:
    CONNECT TO stores_demo@france

    Use the onstat -x option to display the coordinator for a distributed transaction. For more information, see Monitor a global transaction.

  • Each participant directs the execution of one transaction branch, which is the part of the global transaction involving a single local database. A global transaction includes several transaction branches when:
    • An application uses multiple processes to work for a global transaction
    • Multiple remote applications work for the same global transaction

    In When the two-phase commit protocol is used, the participants are france and australia. The coordinator database server, italy, also functions as a participant because it is also doing an update.

The two-phase commit protocol relies on two kinds of communication, messages and logical-log records:
  • Messages pass between the coordinator and each participant. Messages from the coordinator include a transaction identification number and instructions (such as prepare to commit, commit, or roll back). Messages from each participant include the transaction status and reports of action taken (such as can commit or cannot commit, committed, or rolled back).
  • Logical-log records of the transaction are kept on disk or tape to ensure data integrity and consistency, even if a failure occurs at a participating database server (participant or coordinator).

    For more details, see Two-phase commit and logical-log records.