9.4.1.1 Prerequisites for a Transaction Commit

For tpcommit() to succeed, the following conditions must be true:

  • The calling process must be the same one that initiated the transaction with a call to tpbegin().
  • The calling process must have no transactional replies (calls made without the TPNOTRAN flag) outstanding.
  • The transaction must not be in a rollback-only state and must not be timed out.

If the first condition is false, the call fails and tperrno(5) is set to TPEPROTO, indicating a protocol error. If the second or third condition is false, the call fails and tperrno() is set to TPEABORT, indicating that the transaction has been rolled back. If tpcommit() is called by the initiator with outstanding transaction replies, the transaction is aborted and those reply descriptors associated with the transaction become invalid. If a participant calls tpcommit() or tpabort(), the transaction is unaffected.

A transaction is placed in a rollback-only state if any service call returns TPFAIL or indicates a service error. If tpcommit() is called for a rollback-only transaction, the function cancels the transaction, returns -1, and sets tperrno(5) to TPEABORT. The results are the same if tpcommit() is called for a transaction that has already timed out: tpcommit() returns -1 and sets tperrno() to TPEABORT. Refer to Managing Errors for more information on transaction errors.