Here is another test I did. I threw a SQLException in the DB.commit phase :
1) DB.prepare()
2) JMS.prepare()
3) DB.commit()
-> throws an XAException
4) JMS.commit() --> No recovery is happening. I expect recovery to do a rollback of the prepared transaction
The full trace (I tried to highlight in bold what seems important):
19:53:42,444 WARN [com.arjuna.ats.jta] (default task-3 : callProgram.xhtml-ADMIN@fr) ARJUNA016036:
commit on < formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS > (XAResourceWrapperImpl@2d2c35d4[xaResource=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@3eaeb01c pad=false overrideRmValue=null productName=
PostgreSQL productVersion=12.12 jndiName=java:/jdbc/AofDS])
failed with exception $XAException.XAER_RMERR: org.postgresql.xa.PGXAException: Error committing prepared transaction. commit xid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS >, preparedXid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS >, currentXid=null
at org.pos...@42.2.20//org.postgresql.xa.PGXAConnection.commitPrepared(PGXAConnection.java:614)
...
Caused by: java.sql.SQLException: ko
19:57:17,629 WARN [com.arjuna.ats.jta] (default task-3 : callProgram.xhtml-ADMIN@fr) ARJUNA016045:
attempted rollback of < formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c60, subordinatenodename=null, eis_name=java:/
JmsXA NodeId:f33f4cde-bf55-11ec-a57b-9cb6d0fa80ff > (XAResourceWrapperImpl@49e48f8f[xaResource=org.jboss.activemq.artemis.wildfly.integration.WildFlyActiveMQXAResourceWrapper@66e65497 pad=false overrideRmValue=null productName=ActiveMQ Artemis productVersion=2.0 jndiName=java:/JmsXA NodeId:f33f4cde-bf55-11ec-a57b-9cb6d0fa80ff]) f
ailed with exception code XAException.XAER_RMFAIL: javax.transaction.xa.XAException
at org.apache.ac...@2.16.0//org.apache.activemq.artemis.core.client.impl.ClientSessionImpl.rollback(ClientSessionImpl.java:1880)
...
Caused by: org.apache.activemq.artemis.api.core.ActiveMQInterruptedException: java.lang.InterruptedException
at org.apache.ac...@2.16.0//org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:506)
at org.apache.ac...@2.16.0//org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:434)
at org.apache.ac...@2.16.0//org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext.xaRollback(ActiveMQSessionContext.java:667)
at org.apache.ac...@2.16.0//org.apache.activemq.artemis.core.client.impl.ClientSessionImpl.rollback(ClientSessionImpl.java:1858)
... 153 more
Caused by: java.lang.InterruptedException at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2197)
at org.apache.ac...@2.16.0//org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:504)
19:57:43,370 WARN [com.arjuna.ats.arjuna] (default task-3 : callProgram.xhtml-ADMIN@fr) ARJUNA012091:
Top-level abort of action 0:ffffac1001a3:-d0caef9:649dc2b0:c52
received TwoPhaseOutcome.FINISH_ERROR from com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord
19:58:26,505 WARN [com.arjuna.ats.jta] (default task-3 : callProgram.xhtml-ADMIN@fr) ARJUNA016006:
XAResourceRecord forget failed: - forget threw exception: org.postgresql.xa.PGXAException: Heuristic commit/rollback not supported. forget xid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS >
at org.pos...@42.2.20//org.postgresql.xa.PGXAConnection.forget(PGXAConnection.java:631)
19:59:13,492 ERROR [org.jboss.as.ejb3.invocation] (default task-3 : callProgram.xhtml-ADMIN@fr) WFLYEJB0034: Jakarta Enterprise Beans Invocation failed on component TestService for method public void com.real.aof.business.service.TestService.testXA(com.real.aof.session.bean.CurrentUser) throws java.lang.Exception: javax.ejb.EJBTransactionRolledbackException: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
at org.jbos...@23.0.2.Final//org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:117)
...
Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
at org.jboss.jts//com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1307)
...
Suppressed: org.postgresql.xa.PGXAException: Error committing prepared transaction. commit xid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS >, preparedXid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS >, currentXid=null
at org.pos...@42.2.20//org.postgresql.xa.PGXAConnection.commitPrepared(PGXAConnection.java:614)
...
Caused by: java.sql.SQLException: ko
at org.pos...@42.2.20//org.postgresql.xa.PGXAConnection.commitPrepared(PGXAConnection.java:591)
Periodic recovery kicks in :
20:00:36,496 WARN [com.arjuna.ats.arjuna] (Periodic Recovery)
Transaction 0:ffffac1001a3:-d0caef9:649dc2b0:c52
has 1 heuristic participant(s)!
20:00:36,496 WARN [com.arjuna.ats.jta] (Periodic Recovery)
XAResourceRecord restored heuristic instance: XAResourceRecord < resource:XAResourceWrapperImpl@2bac8686[xaResource=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@694092b8 pad=false overrideRmValue=null productName=PostgreSQL productVersion=12.12 jndiName=java:/jdbc/AofDS], txid:< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS >,
heuristic: TwoPhaseOutcome.HEURISTIC_ROLLBACK, product: PostgreSQL/12.12, jndiName: java:/jdbc/AofDS com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord@50a8d615 >
20:00:36,496 WARN [com.arjuna.ats.arjuna] (Periodic Recovery)
Transaction 0:ffffac1001a3:-d0caef9:649dc2b0:c52
restored heuristic participant XAResourceRecord < resource:XAResourceWrapperImpl@2bac8686[xaResource=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@694092b8 pad=false overrideRmValue=null productName=PostgreSQL productVersion=12.12 jndiName=java:/jdbc/AofDS], txid:< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS >,
heuristic: TwoPhaseOutcome.HEURISTIC_ROLLBACK, product: PostgreSQL/12.12, jndiName: java:/jdbc/AofDS com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord@50a8d615 >
20:02:46,489 WARN [com.arjuna.ats.arjuna] (Periodic Recovery) Transaction 0:ffffac1001a3:-d0caef9:649dc2b0:c52 has 1 heuristic participant(s)!
20:02:46,489 WARN [com.arjuna.ats.jta] (Periodic Recovery) XAResourceRecord restored heuristic instance: XAResourceRecord < resource:XAResourceWrapperImpl@30025a47[xaResource=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@694092b8 pad=false overrideRmValue=null productName=PostgreSQL productVersion=12.12 jndiName=java:/jdbc/AofDS], txid:< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS >, heuristic: TwoPhaseOutcome.HEURISTIC_ROLLBACK, product: PostgreSQL/12.12, jndiName: java:/jdbc/AofDS com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord@36488d04 >
20:02:46,489 WARN [com.arjuna.ats.arjuna] (Periodic Recovery) Transaction 0:ffffac1001a3:-d0caef9:649dc2b0:c52 restored heuristic participant XAResourceRecord < resource:XAResourceWrapperImpl@30025a47[xaResource=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@694092b8 pad=false overrideRmValue=null productName=PostgreSQL productVersion=12.12 jndiName=java:/jdbc/AofDS], txid:< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c52, node_name=1, branch_uid=0:ffffac1001a3:-d0caef9:649dc2b0:c56, subordinatenodename=null, eis_name=java:/jdbc/AofDS >, heuristic: TwoPhaseOutcome.HEURISTIC_ROLLBACK, product: PostgreSQL/12.12, jndiName: java:/jdbc/AofDS com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord@36488d04 >
.... continues forever .....