users@glassfish.java.net

[gf-users] Re: DB operations under XA don't seem to be transactional

From: Pawel Veselov <pawel.veselov_at_gmail.com>
Date: Tue, 13 May 2014 18:11:23 -0700

All right, I found how to fix it (switching to UserTransaction), and I do
believe it's a GF bug. The JavaDoc for both TransactionManager and
UserTransaction are the same when it comes to begin()/commit()/rollback()
methods. I tend to use TransactionManager because it also allows to
suspend/resume transactions, which I also need. In all case, using
UserTransaction to manage transactions, and TransactionManager to
suspend/resume transactions only seem to work fine. Here is the same test,
updated: http://pastebin.com/Qfs7tSPQ

On Tue, May 13, 2014 at 4:58 PM, Pawel Veselov <pawel.veselov_at_gmail.com>wrote:

>
> Hi.
>
> I'm trying to understand if I'm missing something here...
>
> I'm trying to do simple DB operation within XA transaction. The DB
> connection that I get from the pool does have auto-commit set to 'true',
> which is what it's supposed to be for XA. However, attempting to roll-back
> the whole of XA transaction doesn't do anything, and my changes are still
> in the DB.
>
> The process I'm using for obtaining an XA connection is - open an XA
> transaction, and look up a connection from a XA pool. May be somehow the
> connection is not associating with the XA transaction, but I'm not sure
> what's the correct way to associate that.
>
> Any pointers will be greatly appreciated. Below is the relevant info, the
> JSP deploys in an empty WAR. The JSP outputs:
>
> Before: 3
> After: 4
>
> but should output the same numeric value, as the 'update' operation it
> does on a table should be rolled back.
>
> JDBC config from domain.xml : http://pastebin.com/QHJNx84u
>
> transaction properties (from asadmin get gfservercf.*):
> gfserver.transaction-service.automatic-recovery=true
> gfserver.transaction-service.heuristic-decision=rollback
> gfserver.transaction-service.keypoint-interval=65536
> gfserver.transaction-service.retry-timeout-in-seconds=600
> gfserver.transaction-service.timeout-in-seconds=0
> gfserver.transaction-service.tx-log-dir=${com.sun.aas.instanceRoot}/logs
> gfserver.resource-ref.mi_pe.enabled=true
> gfserver.resource-ref.mi_pe.ref=mi_pe
>
> Test JSP: http://pastebin.com/TwVJRJeK
>
>