The following routines make up the two-phase commit service:
Routine |
Description |
---|---|
Tells the commit service to abort the transaction. |
|
Builds a name string for use by each participating Adaptive Server Enterprise for its begin transaction and prepare transaction statements. This string encodes the application’s transaction name, the commit service name, and the commid. |
|
Closes the connection with the commit service. |
|
Tells the commit service to commit the transaction. |
|
Opens a connection with the commit service. The routine 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. |
|
Decrements the count of servers still participating in the transaction. |
|
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. |
Two additional routines are used for ongoing status reports:
Routine |
Description |
---|---|
Returns the status of a single transaction or all distributed transactions. |
|
Returns the completion status of a distributed transaction. |
During the course of a session, the diagnostic routines scan_xact and stat_xact are used to check that the commit service carried out the request.
The scan_xact routine uses the commit service lookup table, spt_committab, which holds the following values:
Transaction ID
Time the transaction started
Last time the row was updated
Number of servers initially involved in the transaction
Number of servers that have not yet completed
Status: “a” (abort), “c” (commit), “b” (begin)
Application name
Transaction name
The two-phase commit routines call internal stored procedures (for example, sp_start_xact) that are created in each server’s master database. The installmaster script creates the commit service lookup table and stored procedures in each server’s master database, for use whenever that server becomes a commit server.