1.3.2.2 Single-Phase Commit

If a transaction manager has exactly one subordinate Phase One enlistment, the transaction manager attempts to perform the single-phase commit optimization. In this case, the transaction manager sends the subordinate participant a request to perform a single-phase commit, instead of the standard Phase One Prepare request. This optimization delegates the right to decide the transaction outcome to the subordinate.

The subordinate accepts this delegation by making an outcome decision and eventually notifying the transaction manager; or it rejects the Single-Phase Commit request by responding Prepared. In the latter case, the transaction manager makes its own outcome decision and then engages in a standard Phase Two exchange with the participant.

There is a possible disadvantage to this optimization: if the transaction manager loses contact with the subordinate participant after sending the Single-Phase Commit request but before receiving an outcome notification, it has no reliable mechanism for recovering the actual outcome of the transaction. Consequently, the transaction manager sends an In Doubt outcome to any applications or voters awaiting informational outcome notification.

The single-phase commit optimization can be used by any transaction manager that has exactly one Phase One subordinate enlistment, not just the root transaction manager. For example, if transaction manager A has only transaction manager B as a subordinate enlistment, then A can use the single-phase commit optimization with B. If in the same transaction, B has only transaction manager C as a subordinate enlistment, it too can use the single-phase commit optimization with C. This is true regardless of the number of subordinate enlistments that are registered with C.

Note that a non-root transaction manager performs only the single-phase commit optimization if its own superior transaction manager has sent it a Single-Phase Commit request.

The following figure shows the Single-Phase Commit flow.

Single-Phase Commit flow

Figure 6: Single-Phase Commit flow