3 Replies Latest reply on Sep 3, 2008 8:26 AM by Mark Little

    Error or RuntimeException in Synchronization.afterCompletion

    Carlo de Wolf Master

      If I throw an AssertionError in afterCompletion from a Synchronization. I would expect the tx.commit() to throw an exception. Now I only get a log line:

      10:04:25,459 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_4b] TwoPhaseCoordinator.afterCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@543cb1 with error java.lang.AssertionError: forcing an AssertionError in afterCompletion


        • 1. Re: Error or RuntimeException in Synchronization.afterComple
          Adrian Brock Master

           

          "wolfc" wrote:
          If I throw an AssertionError in afterCompletion from a Synchronization. I would expect the tx.commit() to throw an exception.


          Why?

          It's valid for the JTA implementation to do:

          Psuedo code:
          commit()
          {
           resources.end();
           synchronizations.beforeCompletion();
           resources.prepare();
           log.writeResult(); // HERE we know/record the result of the commit (modulo heuristics)
           threadPool.submit(commitPhase);
           removeThreadAssociation();
           return;
          }
          


          so the rollback()/commit()/afterCompletion()s could be executed
          after the call to tm/tx.commit() has returned to you.

          it would also be wrong to signal a transaction failure, if it actually committed
          but one of the afterCompletions buggily threw an exception.

          • 2. Re: Error or RuntimeException in Synchronization.afterComple
            Carlo de Wolf Master

             

            "adrian@jboss.org" wrote:
            Why?

            Because I want to be notified that one of my buggily afterCompletions went wrong. ;-)
            "adrian@jboss.org" wrote:
            It's valid for the JTA implementation to do:

            Psuedo code:
            commit()
            {
             resources.end();
             synchronizations.beforeCompletion();
             resources.prepare();
             log.writeResult(); // HERE we know/record the result of the commit (modulo heuristics)
             threadPool.submit(commitPhase);
             removeThreadAssociation();
             return;
            }
            


            so the rollback()/commit()/afterCompletion()s could be executed
            after the call to tm/tx.commit() has returned to you.

            Shoot, the JTA spec is missing the Corba OTS 2.14.1.2:
            "Corba OTS" wrote:
            Before doing so, however, it first issues after_completion to any registered
            synchronizations and, after all responses are received, replies to the client.

            "adrian@jboss.org" wrote:
            it would also be wrong to signal a transaction failure, if it actually committed
            but one of the afterCompletions buggily threw an exception.

            Yes, I agree. It would be nice if it had some facility to report warnings of such in a different manner.

            Ah well, such is life.

            • 3. Re: Error or RuntimeException in Synchronization.afterComple
              Mark Little Master

              Even in the OTS, after_completion is a best-effort. Since it has no affect on the outcome of the transaction, some implementations ignore calling it entirely for certain types of participants. You should never rely on after_completion being called.