-
1. Re: LRCO Technique with Narayana in Spring+Tomcat
tomjenkinson Dec 5, 2016 5:27 AM (in response to cijuj)Hi Ciju,
To be a last resource an XAResource (wrapper if necessary) just needs to implement LastResourceCommitOptimization (https://github.com/jbosstm/narayana/blob/master/ArjunaJTA/jta/classes/com/arjuna/ats/jta/resources/LastResourceCommitOptimisation.java) of Narayana.
To be sure its working, add your breakpoint here:
You will see we have an additional technique called commit markable resources too. This makes LRCO safer as by default it has the possibility for failure (it is described here: 11.3.2. About the LRCO Optimization for Single-phase Commit (1PC) )
Hope that helps,
Tom
-
2. Re: LRCO Technique with Narayana in Spring+Tomcat
cijuj Dec 5, 2016 12:21 PM (in response to tomjenkinson)Thank you Tom. Do you have any sample/quick-start code in a Spring + Tomcat + Hibernate setup that I can use as a reference ?
Regards,
Ciju
-
3. Re: LRCO Technique with Narayana in Spring+Tomcat
tomjenkinson Dec 6, 2016 5:37 AM (in response to cijuj)I don't have a complete example but some of the techniques are illustrated here:
https://github.com/jbosstm/quickstart
However I would say that you won't find the LRCO example there. To make the XADS LRCO you could use the example you pointed to but manually wrap the PGXADataSource such that the getXAConnection::getXAResource that is returned implements our interface. Alternatively you could use IronJacamar (quickstart/jca-and-tomcat at master · jbosstm/quickstart · GitHub ) to get the DS as that can wrap with the right interface.
-
4. Re: LRCO Technique with Narayana in Spring+Tomcat
cijuj Dec 6, 2016 10:02 PM (in response to tomjenkinson)Thanks Tom, that makes sense.
Now, I'm not sure if I'm doing the right thing. Since I'm using MariaDB connector, I just modified org.mariadb.jdbc.MariaXaResource (mariadb-connector-j/MariaXaResource.java at master · MariaDB/mariadb-connector-j · GitHub to implement com.arjuna.ats.jta.resources.LastResourceCommitOptimisation instead of javax.transaction.xa.XAResource. I then get the following errors and warnings.
com.arjuna.ats.jta - ARJUNA016061: TransactionImple.enlistResource - XAResource.start returned: XAException.XAER_RMFAIL for < formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffc0a81d7b:ce00:58475d90:c, node_name=1, branch_uid=0:ffffc0a81d7b:ce00:58475d90:e, subordinatenodename=null, eis_name=0 >
javax.transaction.xa.XAException
Error querying database. Cause: java.sql.SQLException: Unable to enlist connection in transaction: enlistResource returns 'false'.
-
5. Re: LRCO Technique with Narayana in Spring+Tomcat
tomjenkinson Mar 13, 2017 8:57 AM (in response to cijuj)Sorry, my information was incomplete. The RMFAIL is because Galera likely won't take these XA directives. As you are already editing the source of Galera you could make further changes to prevent the XA calls ending up as XA directives on the driver.
Here is the IronJacamar XA wrapper for LastResources:
You would really need to make all those changes, not just change the interface.
As you can see, things like xa_start are then mapped to the local transaction begin and so forth.
An alternative is to add the LRCO/CMR facility to transactional driver if you would be able to move to using that (normal XA example over here: quickstart/spring/jta at master · jbosstm/quickstart · GitHub ). If you would like me to investigate that let me know and I will see how feasible it would be.
I link to the docs for this item:
-
6. Re: LRCO Technique with Narayana in Spring+Tomcat
cijuj Dec 8, 2016 8:04 PM (in response to tomjenkinson)Thanks Tom. I'm yet to try it out. I'll keep you posted if I make any progress.
-
7. Re: LRCO Technique with Narayana in Spring+Tomcat
tomjenkinson Dec 9, 2016 4:46 AM (in response to cijuj)Thanks for the update - good luck!
-
8. Re: LRCO Technique with Narayana in Spring+Tomcat
tomjenkinson Jan 16, 2017 5:06 AM (in response to cijuj)Hi,
Just wondering how this went?
Thanks,
Tom