3 Replies Latest reply on Dec 18, 2015 11:25 AM by Michael Musgrove

    Shouldn't a failed commit during one-phase commit optimization let EJB invocation fail?

    Torsten Römer Newbie

      In WildFly 8.2.1.Final, I have an entity manager (Oracle XA datasource) and a JCA resource adapter supporting LocalTransaction in one transaction.

       

      Following scenario:

      • An entity with values equal to those in the database is merged
      • The commit() of the local-tx resource fails and throws a ResourceException

      All that happens is a warning being logged:

       

      00:34:47,619 WARN  [com.arjuna.ats.jta] (default task-24) ARJUNA016039: onePhaseCommit on < formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffff7f000101:25752588:566c9884:209, node_name=1, branch_uid=0:ffff7f000101:25752588:566c9884:211, subordinatenodename=null, eis_name=java:/FileDataSource > (LocalXAResourceImpl@41ac4d[connectionListener=d5fa3f connectionManager=1e7041 warned=false currentXid=null productName=Generic JCA productVersion=1.0 jndiName=java:/FileDataSource]) failed with exception XAException.XA_RBROLLBACK: org.jboss.jca.core.spi.transaction.local.LocalXAException: IJ001156: Could not commit local transaction

          at org.jboss.jca.core.tx.jbossts.LocalXAResourceImpl.commit(LocalXAResourceImpl.java:180) [ironjacamar-core-impl-1.1.9.Final.jar:1.1.9.Final]

          at com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource.commit(XAOnePhaseResource.java:113)

          at com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord.topLevelPrepare(LastResourceRecord.java:152)

          at com.arjuna.ats.arjuna.coordinator.AbstractRecord.topLevelOnePhaseCommit(AbstractRecord.java:428)

          at com.arjuna.ats.arjuna.coordinator.BasicAction.onePhaseCommit(BasicAction.java:2317)

          at com.arjuna.ats.arjuna.coordinator.BasicAction.prepare(BasicAction.java:2110)

          at com.arjuna.ats.arjuna.coordinator.BasicAction.End(BasicAction.java:1481)

          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:96)

          at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:162)

          at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1166)

          at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126)

          at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)

          at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:93) [wildfly-ejb3-8.2.1.Final.jar:8.2.1.Final]

       

      and the EJB invocation succeeds.

       

      Debugging JBoss Transaction Manager code, the following happens:

      - Since the merge doesn't do an actual update, the outcome of the prepare phase is TwoPhaseOutcome.PREPARE_READONLY

      - So, 1PC optimization is applied and a one phase commit is done, whose outcome is TwoPhaseOutcome.ONE_PHASE_ERROR since commit() throws a ResourceException

      - The error is not considered, the outcome is TwoPhaseOutcome.PREPARE_ONE_PHASE_COMMITTED, the transaction completes and a warning is logged

       

      I think this is unexpected - I would expect the EJB to receive a RollbackException since the commit failed with XAException.XA_RBROLLBACK.

       

      I also think it is inconsistent - because the transaction fails as expected if:

      - The LocalTransaction resource whose commit() fails is the only participant in the transaction (so it is a "normal" 1PC, not a 2PC that was 1PC optimized)

      - The outcome of the XA datasource is not TwoPhaseOutcome.PREPARE_READONLY (so 1PC optimization is not applied)

       

      So I reported this as a bug: [JBTM-2584] Failed commit during one-phase commit optimization only logs warning and lets EJB invocation succeed - JBoss…

       

      What is your take on this? What would you expect to happen - just a warning or the transaction to fail?