Two-Phase Commit Functions

The functions that make up the two-phase commit service are as follows:

open_commit
Opens a connection with the commit service. The function is given the login ID of the user initiating the session and the name of the commit service. It returns a pointer to a DBPROCESS structure used in subsequent commit service calls.
start_xact
Records the start of a distributed transaction and stores initial information about the transaction (DBPROCESS ID, application name, transaction name, and number of sites participating) in a lookup table on the commit server. It returns the commid identifying number for the transaction.
build_xact_string
Builds a name string for use by each participating SQL Server for its BEGIN TRANSACTION and PREPARE TRANSACTION statements. This string encodes the application's transaction name, the commit service name, and the commid.
commit_xact
Tells the commit service to commit the transaction.
abort_xact
Tells the commit service to cancel the transaction.
remove_xact
Decreases the number of servers still participating in the transaction.
close_commit
Closes the connection with the commit service.

Two additional functions are used for ongoing status reports:

scan_xact
Returns the status of a single transaction or all distributed transactions.
stat_xact
Returns the completion status of a distributed transaction.

During a session, the diagnostic functions, scan_xact and stat_xact, check that the commit service carried out the request.

The scan_xact function uses the commit service lookup table, spt_committab, which holds the values of the following:

The two-phase commit functions call internal stored procedures (for example, sp_start_xact) that are created in each server's master database. The INSTMSTR.SQL script creates the commit service lookup table and stored procedures in each server's master database for use whenever the server becomes a commit server.