3.2 Example 2: Commit a Transaction

This example demonstrates how a transaction is committed, as described in the use case Complete a Transaction – Application (section 2.5.2). A transaction is committed if all the subordinate participants involved in the transaction are prepared to commit the changes.

Prerequisites:

  • Transaction processing services protocols meet all the preconditions as described in section 2.4.

  • Transaction processing services are operational.

  • The application can access a transaction manager in the system.

  • Transaction work is performed.

Initial System State

A transaction is performed by resource managers and their respective transaction managers.

Final System State

The two-phase commit has been done to complete the transaction.

Sequence of Events

The messages that are exchanged in this example are contained within the two-phase commit notifications action between the system and participating roles.

Example of committing a transaction

Figure 13: Example of committing a transaction

The following steps describe this sequence:

  1. The root transaction manager sends a TXUSER_ENLISTMENT_MTAG_PREPAREREQ message to the resource manager over the CONNTYPE_TXUSER_ENLISTMENT connection, as specified in [MS-DTCO] section 4.5.1.1, indicating that this is a two-phase commit.

  2. The root transaction manager sends a PARTNERTM_PROPAGATE_MTAG_PREPAREREQ message to the remote transaction manager over the CONNTYPE_PARTNERTM_BRANCH connection, as specified in [MS-DTCO] section 4.5.1.2, indicating that this is a two-phase commit.

  3. The resource manager sends a TXUSER_ENLISTMENT_MTAG_PREPAREREQDONE message to the root transaction manager, indicating that the prepare request finished successfully (TXUSER_ENLISTMENT_PREPAREREQDONE_OK), as specified in [MS-DTCO] section 4.5.1.1, completing step 1.

  4. The remote transaction manager sends a TXUSER_ENLISTMENT_MTAG_PREPAREREQ message to the remote resource manager over the CONNTYPE_TXUSER_ENLISTMENT connection, as specified in [MS-DTCO] section 4.5.1.1, indicating that this is a two-phase commit.

  5. The remote resource manager sends a TXUSER_ENLISTMENT_MTAG_PREPAREREQDONE message to the remote transaction manager, indicating that the prepare request finished successfully (TXUSER_ENLISTMENT_PREPAREREQDONE_OK) as specified in [MS-DTCO] section 4.5.1.1, completing step 4.

  6. The remote transaction manager sends a PARTNERTM_PROPAGATE_MTAG_PREPAREREQDONE to the root transaction manager, indicating that the prepare request finished successfully (OK), as specified in [MS-DTCO] section 4.5.1.2, completing step 2.

  7. The root transaction manager sends a TXUSER_BEGIN2_MTAG_SINK_ERROR message to the application over the CONNTYPE_TXUSER_BEGIN2 connection, as specified in [MS-DTCO] section 4.1.2.1, by indicating that the transaction has committed (TRUN_TXBEGIN_ERROR_NOTIFY_COMMITTED), completing step 21 in Example 1: Perform Transaction Work (section 3.1).

  8. The root transaction manager sends a TXUSER_ENLISTMENT_MTAG_COMMITREQ message to the resource manager over the CONNTYPE_TXUSER_ENLISTMENT connection, as specified in [MS-DTCO] section 4.4.3.2.

  9. The root transaction manager sends a PARTNERTM_PROPAGATE_MTAG_COMMITREQ message to the remote transaction manager over the CONNTYPE_PARTNERTM_BRANCH connection, as specified in [MS-DTCO] section 4.5.2.2.

  10. The remote transaction manager sends a TXUSER_ENLISTMENT_MTAG_COMMITREQ message to the remote resource manager over the CONNTYPE_TXUSER_ENLISTMENT connection, as specified in [MS-DTCO] section 4.4.3.2.

  11. The resource manager sends a TXUSER_ENLISTMENT_MTAG_COMMITREQDONE message to the root transaction manager, completing step 8, and initiates the disconnect sequence on the CONNTYPE_TXUSER_ENLISTMENT connection with the root transaction manager, as specified in [MS-DTCO] section 4.4.3.2.

  12. The remote resource manager sends a TXUSER_ENLISTMENT_MTAG_COMMITREQDONE message to the remote transaction manager, completing step 8, and initiates the disconnect sequence on the CONNTYPE_TXUSER_ENLISTMENT connection with the remote transaction manager, as specified in [MS-DTCO] section 4.4.3.2.

  13. The remote transaction manager sends a PARTNERTM_PROPAGATE_MTAG_COMMITREQDONE message to the root transaction manager, completing step 9, and initiates the disconnect sequence, as specified in [MS-DTCO] section 4.5.2.2.

  14. The remote transaction manager sends a success message to the application service, notifying it of the completion of the two-phase commit sequence.