libndrxxapq

Name

libndrxxapq — Enduro/X PostgreSQL PQ XA Driver

Synopsis

libndrxxapq.so libndrxxapq.dylib

NDRX_XA_RES_ID=1
NDRX_XA_OPEN_STR={"url":"tcp:postgresql://${EX_PG_HOST}/${EX_PG_DB}"
        ,"user":"${EX_PG_USER}"
        ,"password":"${EX_PG_PASS}"
        ,"compat":"PGSQL|INFORMIX|INFORMIX_SE"
        }"
NDRX_XA_CLOSE_STR=$NDRX_XA_OPEN_STR
NDRX_XA_DRIVERLIB=libndrxxapq.so
NDRX_XA_RMLIB=-
NDRX_XA_LAZY_INIT=1

DESCRIPTION

This is XA driver specifically written Enduro/X needs. It provides an XA switch emulation on top of PostgreSQL prepared transactions. PostgreSQL by default does not support XA switch. Also when transaction start, there is no possibility to identify the work unit performed. The identification of work done by some process on particular connection can be done by preparing the transaction. Thus there is no such thing as "active" transaction in terms of XA specification. Also there is no possibility for other processes to join the existing work and see work done by other session. Thus for example if one server process in same transaction performs some insert and other process tries insert on table which has foreign key to first insert, it will fail, as FK will not be seen. Thus Enduro/X needs to work on branch-transactions mode without join feature. The mode of PostgreSQL driver is the same as enabled by NDRX_XA_FLAG with value NOJOIN.

The emulation of XA protocol is done by following steps and assumptions:

  1. When process joins to global transaction, new branch-transaction-id is acquired. The TMSRV logs the branch with status u-unknown.
  2. When process completes the work unit (server does tpreturn(3) or tpforward(3)) or initiating process performs tpcommit(3), the xa_end() is called which in-turn runs PostgreSQL "PREPARE TRANSACTION <XID_STR>". "XID_STR" is based on PosgreSQL JDBC driver format. Thus JDBC version on PQ versions of tmsrv drivers can be mixed. When transaction is prepared OK, the TMSRV is reported with p-prepared status. If prepare fails, this means that transaction is aborted by PosgreSQL, and in this case a-aborted status is reported to TMSRV.
  3. When TMSRV tries to commit, and branch is in u-unknown or a-aborted status, the global transaction is aborted and tpcommit caller receives TPEABORT error. If transaction is in status p, the prepare phase of global transaction is skipped/no operation and then commit is executed.
  4. In case if work unit performs too long operation and tries to xa_end() after when TMSRV is already timed-out/rolled back the global transaction, the xa_end() status call to TMSRV fails with error