Completing prepared transactions

WARNING! Heuristically completing a prepared transaction can cause inconsistent results for an entire distributed transaction. The System Administrator’s decision to heuristically commit or roll back a transaction may contradict the decision made by the coordinating Adaptive Server or transaction protocol.

Before heuristically completing a transaction, the System Administrator should make every effort to determine whether the coordinating Adaptive Server or transaction protocol decided to commit or roll back the distributed transaction (see “Determining the commit status for Adaptive Server transactions”).

By using dbcc complete_xact, the System Administrator forces Adaptive Server to commit or roll back a branch of a distributed transaction. After heuristically completing a prepared transaction, Adaptive Server records the transaction’s commit status in master.dbo.systransactions so that the transaction’s coordinator—Adaptive Server, MSDTC, or an X/Open XA transaction manager—can know whether the transaction was committed or rolled back.

Adaptive Server propagates the command to heuristically commit or abort a transaction to any participant servers that it coordinated for the transaction branch. For example, if in Figure 8-2 you heuristically commit the transaction on ASE2, ASE2 propagates the command to ASE4 so that the transaction on ASE4 also commits.

dbcc complete_xact requires that you supply an active transaction name and desired outcome for the transaction. For example, the following command heuristically commits a transaction:

dbcc complete_xact "00000b1700040000dd6821390001-aa01f04ebb9a-00000b1700040000dd6821390001-aa01f04ebb9a-caserv1-caserv1-0002", "commit"

Forgetting heuristically completed transactions

When the System Administrator heuristically completes a prepared transaction, Adaptive Server maintains information about the transaction’s commit status in master.dbo.systransactions. This information is maintained so external transaction coordinators can detect the presence of heuristically completed transactions.

If the external coordinator is another Adaptive Server, the server examines the commit status and logs a warning message if the heuristic completion conflicts with the commit status of the distributed transaction. After examining the commit status, the coordinating Adaptive Server clears the commit status information from systransactions.

If the external coordinator is an X/Open XA-compliant transaction manager, the transaction manager does not log warning message when the heuristic completion conflicts with the distributed transaction. However, X/Open XA-compliant transaction managers clear the commit status information from systransactions.


Manually clearing the commit status

dbcc forget_xact purges the commit status of a heuristically completed transaction from systransactions. It can be used when the System Administrator does not want the coordinating service to have knowledge that a transaction was heuristically completed, or when an external coordinator will not be available to clear information from systransactions.

See dbcc in the Reference Manual: Commands for more information about using dbcc forget_xact.