0001 TX_COMMIT(3)
0002 ============
0003 :doctype: manpage
0004
0005
0006 NAME
0007 ----
0008 tx_commit - Commit a global transaction
0009
0010
0011 SYNOPSIS
0012 --------
0013 #include <tx.h>
0014
0015 int tx_commit(void);
0016
0017 For XATMI client link with '-latmiclt -latmi -lubf -lnstd -lpthread -lrt -lm'
0018
0019 For XATMI server link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm'
0020
0021 DESCRIPTION
0022 -----------
0023 Function commits global transaction associated with current thread
0024 previously started by *tx_begin(3)*. If transaction control was changed by
0025 *tx_set_transaction_control(3)* flag *TX_CHAINED*, the new transaction is started
0026 immediately after the commit.
0027
0028 If commit return was altered by *tx_set_commit_return(3)* and setting flag was
0029 set to *TX_COMMIT_DECISION_LOGGED*, the function will return after transaction
0030 is prepared by resource managers, and final commit (second phase of transaction)
0031 is left for transaction manager (*tmsrv(8)*) to complete by background thread,
0032 executed periodically (configured by *-s* scan time CLI parameter to *tmsrv*).
0033
0034 Function use following attributes set by:
0035
0036 - *tx_set_transaction_control(3)* - if applied with *TX_CHAINED*, new transaction
0037 is started. The default is *TX_UNCHAINED* - meaning after commit, control thread
0038 is no more in global transaction.
0039
0040 - *tx_set_commit_return(3)* - if applied with *TX_COMMIT_DECISION_LOGGED* function
0041 returns when first phase of two phase commit is completed (and second phase
0042 is done by background thread). The default is *TX_COMMIT_COMPLETED* meaning
0043 that function returns when commit is completed.
0044
0045 TX API is base on TP API. This function is based on *tpcommit(3)* and it is possible
0046 to mix these two API kinds.
0047
0048 It is forbidden to perform *tx_commit()* having any transactional outstanding calls.
0049 Enduro/X does not explicitly check such calls in progress (direct and/or subsequent
0050 tpacall, conversational session). If commit is performed in such scenario,
0051 that might result with orphan active transaction branches, or partial commit
0052 even having abort-only marking in outstanding call.
0053
0054 In case if process is joined to the transaction (i.e. it is not an initiator
0055 of the transaction) and tx_commit() is called, the error *TX_PROTOCOL_ERROR* is returned,
0056 process keeps participation in the transaction.
0057
0058 RETURN VALUE
0059 ------------
0060 On success, *tx_commit()* return *TX_OK*; on error, error code is returned
0061
0062 ERRORS
0063 ------
0064
0065 *TX_NO_BEGIN* The transaction committed successfully; however, a new
0066 transaction could not be started and the caller is no longer in transaction mode.
0067 This return value occurs only when the transaction_control characteristic is *TX_CHAINED*.
0068
0069 *TX_ROLLBACK* The transaction could not commit and has been rolled back.
0070 In addition, if the *transaction_control(3)* characteristic is *TX_CHAINED*,
0071 a new transaction is started.
0072
0073 *TX_ROLLBACK_NO_BEGIN* The transaction could not commit and has been rolled back.
0074 In addition, a new transaction could not be started and the caller is no longer
0075 in transaction mode. This return value can occur only when the
0076 *transaction_control(3)* characteristic is *TX_CHAINED*.
0077
0078 *TX_MIXED* The transaction was partially committed and partially rolled back.
0079 In addition, if the *transaction_control(3)* characteristic is *TX_CHAINED*,
0080 a new transaction is started.
0081
0082 *TX_MIXED_NO_BEGIN* The transaction was partially committed and partially
0083 rolled back. In addition, a new transaction could not be started and the caller
0084 is no longer in transaction mode. This return value can occur only when the
0085 *transaction_control(3)* characteristic is *TX_CHAINED*.
0086
0087 *TX_HAZARD* Due to a failure, the transaction may have been partially
0088 committed and partially rolled back. In addition, if the *transaction_control(3)*
0089 characteristic is *TX_CHAINED*, a new transaction is started.
0090
0091 *TX_HAZARD_NO_BEGIN* Due to a failure, the transaction may have been partially
0092 committed and partially rolled back. In addition, a new transaction could
0093 not be started and the caller is no longer in transaction mode. This return
0094 value can occur only when the *transaction_control(3)* characteristic
0095 is *TX_CHAINED*.
0096
0097 *TX_PROTOCOL_ERROR* The function was called in an improper context
0098 (for example, the caller is not in transaction mode). The caller's state
0099 with respect to the transaction is not changed.
0100
0101 *TX_FAIL* Either the transaction manager or one or more of the
0102 resource managers encountered a fatal error. The nature of the error is
0103 such that the transaction manager and/or one or more of the resource managers
0104 can no longer perform work on behalf of the application. The exact
0105 nature of the error can be checked in process and/or transaction manager
0106 log files.
0107
0108 EXAMPLE
0109 -------
0110 See *atmitest/test021_xafull/atmiclt21tx.c* for sample code.
0111
0112 BUGS
0113 ----
0114 Report bugs to support@mavimax.com
0115
0116 SEE ALSO
0117 --------
0118 *tx_begin(3)* *tpcommit(3)* *tx_rollback(3)* *tx_info(3)* *tx_close(3)*
0119 *tx_set_transaction_timeout(3)* *tx_set_transaction_control(3)*
0120 *tx_set_commit_return(3)*
0121
0122 COPYING
0123 -------
0124 (C) Mavimax, Ltd
0125