Not able to configure DB2 as resource manager for endurox

Added by Shrikant 6 months ago

Hi

We installed endurox-7.5.34-5.oracleserver7_3_GNU_epoll.x86_64.rpm on our Redhat 7 OS.
We are attempting to use Postgres 1.3 and IBM DB2 11.1 as resource manager for our POC
We did not find any sample to setup the DB2 instance db as resource manager .
Do you have any specific versions of IBM DB2 which the endurox 7.5.34-5 application supports?

Following are the details of our setup and analysis done

We started with demo server using “xadmin provision -d” and setup the postgres tmsrv successfully .
But we are unable to setup the tmsrv for IBM DB2 database.

Following is the ndrxconfig.xml file setting for us

<server name="tmsrv">
<min>1</min>
<max>1</max>
<srvid>46</srvid>
<cctag>RM1_DB2</cctag>
<sysopt>-e ${NDRX_APPHOME}/log/tmsrv-rm2.log r - -t1 -l${NDRX_APPHOME}/tmlogs/rm2</sysopt>
</server>

Below are the app.ini settings

[@global/RM1_DB2]
NDRX_XA_RES_ID=2
NDRX_XA_OPEN_STR=”db=MG2211CR,uid=dbuser,pwd=Test1234,toc=t”
NDRX_XA_CLOSE_STR=${NDRX_XA_OPEN_STR
NDRX_XA_DRIVERLIB=/endurox/lib64/libndrxxadb2s.so
NDRX_XA_RMLIB=/opt/ibm/db2/V11.1/lib64/libdb2.so
NDRX_XA_LAZY_INIT=1

Below is the output of “xadmin pe | grep NDRX”

NDRX_APPHOME=/home/user10/endurox/workspace/demo
NDRX_HOME=/cls/endurox
NDRX_CCONFIG=/home/user10/endurox/workspace/demo/conf
NDRX_CLUSTERISED=1
NDRX_CMDWAIT=1
NDRX_CONFIG=/home/user10/endurox/workspace/demo/conf/ndrxconfig.xml
NDRX_DMNLOG=/home/user10/endurox/workspace/demo/log/ndrxd.log
NDRX_DPID=/home/user10/endurox/workspace/demo/tmp/ndrxd.pid
NDRX_DQMAX=100
NDRX_IPCKEY=44210
NDRX_LDBAL=0
NDRX_LEV=5
NDRX_LOG=/home/user10/endurox/workspace/demo/log/xadmin.log
NDRX_MSGMAX=100
NDRX_MSGSIZEMAX=56000
NDRX_NODEID=1
NDRX_QPATH=/dev/mqueue
NDRX_QPREFIX=/test2
NDRX_RNDK=0myWI5nu
NDRX_SRVMAX=10000
NDRX_SVCMAX=20000
NDRX_TOUT=90
NDRX_UBFMAXFLDS=16000
NDRX_THREADSTACKSIZE=8192
NDRX_LIBEXT=so
NDRX_ULOG=/home/user10/endurox/workspace/demo/log

On xadmin start -y , this tmsrv keeps crashing with Segmentation fault.

Following are the last few lines from the logs

N:NDRX:5:181d91ac:19401:2aead6527640:000:20211224:055556029560:tpsvrinit :/tmsrv.c:0593:About to initialize XA!
N:NDRX:4:181d91ac:19401:2aead6527640:000:20211224:055556029569:atmi_xa_init:tmi/xa.c:0319:Loading XA driver: [/cls/endurox/lib64/libndrxxadb2s.so]
N:NDRX:4:181d91ac:19401:2aead6527640:000:20211224:055556029660:atmi_xa_init:tmi/xa.c:0358:About to call ndrx_get_xa_switch()
N:NDRX:5:181d91ac:19401:2aead6527640:000:20211224:055556029666:a_switch_int:common.c:0070:Loading Db2 Static reg XA driver
N:NDRX:5:181d91ac:19401:2aead6527640:000:20211224:055556029684:a_switch_int:common.c:0076:db2xacicst_std symbol not found in process address space - loading .so!
N:NDRX:4:181d91ac:19401:2aead6527640:000:20211224:055556038985:atmi_xa_init:tmi/xa.c:0372:Using XA dynamic registration
N:NDRX:5:181d91ac:19401:2aead6527640:000:20211224:055556039001:atmi_xa_init:tmi/xa.c:0389:xa_flags = []
N:NDRX:4:181d91ac:19401:2aead6527640:000:20211224:055556039006:atmi_xa_init:tmi/xa.c:0548:XA lib initialized.
N:NDRX:4:181d91ac:19401:2aead6527640:000:20211224:055556039011:tpsvrinit :/tmsrv.c:0626:DB PING disabled (-P not set)
N:NDRX:5:181d91ac:19401:2aead6527640:000:20211224:055556039015:tpsvrinit :/tmsrv.c:0631:About to Open XA Entry!
N:NDRX:5:181d91ac:19401:2aead6527640:000:20211224:055556039021:a_open_entry:tmi/xa.c:0586:atmi_xa_open_entry RMID=2

Following is the gdb output of the core dump of tmsrv server.

Core was generated by `tmsrv -k 0myWI5nu -i 46 -e /home/user10/endurox/workspace/demo/log/tmsrv-rm2.lo'.

Program terminated with signal 11, Segmentation fault.
#0 0x00002b39b6bd1d1e in atmi_xa_open_entry () at /home/user1/endurox/libatmi/xa.c:595
595 /home/user1/endurox/libatmi/xa.c: No such file or directory.
Missing separate debuginfos, use: debuginfo-install libgcc-4.8.5-44.el7.x86_64 libstdc++-4.8.5-44.el7.x86_64 libxml2-2.9.1-6.el7.5.x86_64 nss-softokn-freebl-3.53.1-6.el7_9.x86_64 pam-1.1.8-23.el7.x86_64 zlib-1.2.7-19.el7_9.x86_64
(gdb) bt full
#0 0x00002b39b6bd1d1e in atmi_xa_open_entry () at /home/user1/endurox/libatmi/xa.c:595
ret = 0
func = "atmi_xa_open_entry"
#1 0x00002b39b675c9a6 in tpsvrinit (argc=12, argv=0x7ffffc84cb68) at /home/user1/endurox/tmsrv/tmsrv.c:632
ret = 0
c = <optimized out>
svcnm = '\000' <repeats 30 times>
func = "tpsvrinit"
nodeid = <optimized out>
#2 0x00002b39b698774b in ndrx_main (argc=12, argv=0x7ffffc84cb68) at /home/user1/endurox/libatmisrv/srvmain.c:1121
ret = 0
env_procname = <optimized out>
env_clopt = 0x0
func = "ndrx_main"
#3 0x00000000004012b1 in main (argc=<optimized out>, argv=<optimized out>) at /home/user1/endurox/tmsrv/tmsrvmain.c:80
tmsvrargs =

{xa_switch = 0x603100 <tmnull_switch>, svctab = 0x6031a0 <ndrx_G_tmdsptchtbl>, flags = 0, p_tpsvrinit = 0x4011c0 <tpsvrinit@plt>, p_tpsvrdone = 0x401210 <tpsvrdone@plt>, reserved0 = 0x0, reserved1 = 0x0, reserved2 = 0x0, reserved3 = 0x0, reserved4 = 0x0, p_tpsvrthrinit = 0x0, p_tpsvrthrdone = 0x0}
(gdb)

On going through the code, we came to conclusion that xa_switch_t pointer returned from db2xacicst_std API call from the DB2 library libdb2.so had the function pointer for xa_open_entry pointer as NULL .

Please provide pointers to how to use the IBM DB2 as a XA resource manager with EnduroX.


Replies (12)

RE: Not able to configure DB2 as resource manager for endurox - Added by Madars 6 months ago

Hi,

Welcome to Enduro/X forums.

Just checked, that DB2 loader driver has a bug, /endurox/lib64/libndrxxadb2s.so resolves loader function db2xacicst_std() instead of XA switch db2xa_switch_static_std.
We will need to rebuild Enduro/X libndrxxadb2s.so to have correct xa switch name, that could be done in the next week, when plan the patch release for Enduro/X 7.5.

There are several things you can do now:

1) If you are familiar with Tuxedo environment, you could use buildtms tools in the same way as with Tuxedo and follow for example this procedure: https://www.ibm.com/docs/en/db2/11.1?topic=managers-bea-tuxedo

In that case the CCTAG would look like this:

ini:

[@global/RM1_DB2]
NDRX_XA_RES_ID=2
NDRX_XA_OPEN_STR=”db=MG2211CR,uid=dbuser,pwd=Test1234,toc=t”
NDRX_XA_CLOSE_STR=${NDRX_XA_OPEN_STR
NDRX_XA_DRIVERLIB=/endurox/lib64/libndrxxatmsx.so
NDRX_XA_RMLIB=-
NDRX_XA_LAZY_INIT=1

And the you need to use custom built tms:

xml:

<server name="output_from_build_tms">
<min>1</min>
<max>1</max>
<srvid>46</srvid>
<cctag>RM1_DB2</cctag>
<sysopt>-e ${NDRX_APPHOME}/log/tmsrv-rm2.log r - -t1 -l${NDRX_APPHOME}/tmlogs/rm2</sysopt>
</server>

This would allow you to proceed with the testing.

By the way, if you are familiar with Tuxedo environment, for Enduro/X version 8.0 (which is not yet released), we will provide automatic tool for configuration migration and we have made extensive migration guide, that I guess would help for 7.5 migrations too, if that is the case, see
https://github.com/endurox-dev/endurox/blob/7.1/doc/migration_tuxedo.adoc

2) Second option if you want to proceed now, would be that you rebuild the Enduro/X by your self, prior updating https://github.com/endurox-dev/endurox/blob/master/xadrv/db2/db2_s.c

< return ndrx_get_xa_switch_int("db2xacicst_std", "Loading Db2 Static reg XA driver"); 
> return ndrx_get_xa_switch_int("db2xa_switch_static_std", "Loading Db2 Static reg XA driver");

PS,

According to IBM, DB2 XA Switch have TMNOMIGRATE flag, this means that additionally you need to add configuration flag NOJOIN, which would enable loose coupling between the transaction branches:

[@global/RM1_DB2]
NDRX_XA_RES_ID=2
NDRX_XA_OPEN_STR=”db=MG2211CR,uid=dbuser,pwd=Test1234,toc=t”
NDRX_XA_CLOSE_STR=${NDRX_XA_OPEN_STR
NDRX_XA_DRIVERLIB=/endurox/lib64/libndrxxatmsx.so
NDRX_XA_RMLIB=-
NDRX_XA_LAZY_INIT=1
NDRX_XA_FLAGS=NOJOIN

If the DB changes needs to be seen between processes, you may try to add BTIGHT flag, such as:

NDRX_XA_FLAGS=NOJOIN;BTIGHT

Though, not sure how well DB2 would support that. In any case, you may try out and provide results. Also when NOJOIN is used, you shall not explicitly use tpsuspend()/tpresume() calls in your software (if they are used, as here tpsuspend() will just end the transaction branch and would not resume it the same thread, instead new branch would be created).

Currently we do no not have test system with DB2, as Enduro/X operates according to XA specification and we are assuming that DB2 complies as well. But in any case if prospects are good we can fine tune our product for DB2 (if that would be required).

RE: Not able to configure DB2 as resource manager for endurox - Added by Madars 6 months ago

Thought if using buildtms option, then DB2 processes shall be built with buildserver/buildclient by using -r parameter.

RE: Not able to configure DB2 as resource manager for endurox - Added by Shrikant 6 months ago

Thank you Madars, we will go through the workaround options and revert if it worked or need more help

RE: Not able to configure DB2 as resource manager for endurox - Added by Madars 6 months ago

We double checked the TMNOMIGRATE setting of DB2 xa switch, and that affects only association migration between a threads, which Enduro/X is not doing. So I guess you could start testing with "NDRX_XA_FLAGS" unset i.e. no specific settings used.

RE: Not able to configure DB2 as resource manager for endurox - Added by Madars 6 months ago

And one more moment:

You do not need quotes around the open/close strings when putting settings in ini file, e.g.:

[@global/RM1_DB2]
NDRX_XA_RES_ID=2
NDRX_XA_OPEN_STR=db=MG2211CR,uid=dbuser,pwd=Test1234,toc=t
NDRX_XA_CLOSE_STR=${NDRX_XA_OPEN_STR}
...

That would be the correct way.

RE: Not able to configure DB2 as resource manager for endurox - Added by Lauris 6 months ago

Hello,

Fixed version have been uploaded: https://www.endurox.org/attachments/download/1524/endurox-7.5.36-1.oracleserver7_3_GNU_epoll.x86_64.rpm

Now correct XA Switch names are being used in DB2 drivers.

RE: Not able to configure DB2 as resource manager for endurox - Added by Shrikant 6 months ago

Hi Madars and Lauris,

Thank you . We were able to successfully configure IBM DB2 with the endurox-7.5.36-1 version . We are able to execute the queries successfully as well

A follow up to this question , we are using Endurox as a Transaction manager with IBM DB2 as resource manager 1 and Postgres as resource manager 2.

Following configuration allows only one RM as part of the tmsrv(transaction manager) in cctag. How do we configure the Postgres resource manager as well as part of this transaction manager? We want to make a DB2 operation and also a Postgres operation as part of a single transaction

&lt;server name="tmsrv"&gt;
&lt;min&gt;1&lt;/min&gt;
&lt;max&gt;1&lt;/max&gt;
&lt;srvid&gt;46&lt;/srvid&gt;
&lt;cctag&gt;RM1_DB2&lt;/cctag&gt;
&lt;sysopt&gt;-e ${NDRX_APPHOME}/log/tmsrv-rm2.log r - -t1 -l${NDRX_APPHOME}/tmlogs/rm2&lt;/sysopt&gt;
&lt;/server&gt;

RE: Not able to configure DB2 as resource manager for endurox - Added by Madars 6 months ago

Hi,

You need to define several different tmsrv for each of the cctag.

You can check sample xml config here: https://github.com/endurox-dev/endurox/blob/master/atmitest/test090_tuxmig/ubb_config1.xml with corresponding ini config here: https://github.com/endurox-dev/endurox/blob/master/atmitest/test090_tuxmig/ubb_config1.ini where several CCTAGs and tmsrvs are used.

The system will automatically join required tmsrvs in the global transaction.

So something like this for your case:


[@global/RM1_DB2]
NDRX_XA_RES_ID=1
NDRX_XA_OPEN_STR=db=MG2211CR,uid=dbuser,pwd=Test1234,toc=t
NDRX_XA_CLOSE_STR=${NDRX_XA_OPEN_STR}
NDRX_XA_DRIVERLIB=/endurox/lib64/libndrxxadb2s.so
NDRX_XA_RMLIB=/opt/ibm/db2/V11.1/lib64/libdb2.so
NDRX_XA_LAZY_INIT=1
NDRX_XA_FLAGS=FDATASYNC;DSYNC

[@global/RM2_PQ]
# remember to have different RES_IDs for each of the CCTAG:
NDRX_XA_RES_ID=2
NDRX_XA_OPEN_STR={ "url":"postgresql://${EX_PG_USER}:${EX_PG_PASS}@${EX_PG_HOST}/${EX_PG_DB}"}
NDRX_XA_CLOSE_STR=${NDRX_XA_OPEN_STR}
NDRX_XA_DRIVERLIB=libndrxxapq.so
NDRX_XA_RMLIB=-
NDRX_XA_LAZY_INIT=1
NDRX_XA_FLAGS=FDATASYNC;DSYNC;NOJOIN;NOSTARTXID

And then in xml config:


<endurox>
...
<servers>
...
<server name="tmsrv">
<min>1</min>
<max>1</max>
<srvid>46</srvid>
<cctag>RM1_DB2</cctag>
<sysopt>-e ${NDRX_APPHOME}/log/tmsrv-rm1.log r - -t1 -l${NDRX_APPHOME}/tmlogs/rm1</sysopt>
</server>

<server name="some_business_binary1">
<cctag>RM1_DB2</cctag>
...
</server>
...

<server name="tmsrv">
<min>1</min>
<max>1</max>
<srvid>146</srvid>
<cctag>RM2_PQ</cctag>
<sysopt>-e ${NDRX_APPHOME}/log/tmsrv-rm2.log r - -t1 -l${NDRX_APPHOME}/tmlogs/rm2</sysopt>
</server>

<server name="some_business_binary2">
<cctag>RM2_PQ</cctag>
...
</server>
...

remember to create: ${NDRX_APPHOME}/tmlogs/rm1 (probably you have already this) and ${NDRX_APPHOME}/tmlogs/rm2.

And another note, by default tmsrv does not fsync to disk at point of transaction commit decision, just fflush. So to guarantee transaction consistency for case of power loss or OS crash, FDATASYNC;DSYNC flags are required, though if slow disks are used for -l${NDRX_APPHOME}/tmlogs, expect low TPS throughput.

Br,
Madars

RE: Not able to configure DB2 as resource manager for endurox - Added by Shrikant 6 months ago

Thank you Madars,

We have setup two tmsrv for each resource manager.
But our business application server needs to make execute both DB2 and Postgres queries in a single transaction.

//code something like below
begin XA transaction
call PG database query
call DB2 database query
commit/rollback XA transaction

We are unable to create this server , since the ND_XA_* config parameters in app.ini correspond to one RM . The query executes for PG, but fails for DB2 and transaction is rolled back.

RE: Not able to configure DB2 as resource manager for endurox - Added by Madars 6 months ago

Hi,

XATMI API does not work this way.

Single xatmi client or server is linked only with one resource, in this case either PG or DB2 according to CCTAG and libraries used...

If you need a transaction which spans over the two or more databases, you need to use following architecture:

1) You create an orchestrator process which will start the global transaction. Orchestrator may live in NULL RM switch/TMSRV, see libndrxxanulls. I.e. dummy resource associate with it.
2) You create a XATMI server/service for works that shall be done under DB2.
3) You create a XATMI server/service for works that shall be done under PG.

And then at runtime:

A) The Orchestrator 2) starts a transaction
B) Orchestrator process calls (i.e. use tpcall() to send request+data) the DB2 XATMI service created at 2). Enduro/X will automatically join the DB2 to the global transaction started at A).
C) Orchestrator process calls the PG service created at 3). The same here, Enduro/X will associate PG work with global txn started at A).
D) Orchestrator commits the transaction.

Hope this help!

Br,
Madars

RE: Not able to configure DB2 as resource manager for endurox - Added by Madars 6 months ago

Also Orchestrator may be any of PG or DB2 services, and they can tpcall() each other as required. The main idea is that each executable works only with on resource and other resources are involved in global transaction via tpcall() or other XATMI apis (i.e. tpacall()/tpgetrply(), tpconnect() + tpsend() + tprecv(), etc.)

RE: Not able to configure DB2 as resource manager for endurox - Added by Shrikant 6 months ago

Thank you for the detailed explanation
We will test our application this way

(1-12/12)