2 Replies Latest reply on Feb 8, 2015 4:43 PM by tomjenkinson

    Issues with calling suspend to disassociate a completed transaction from the thread

    tomjenkinson

      Historically we have advised users that if a transaction is completed by the reaper that they should call suspend/rollback to disassociate the transaction from the thread.

       

      Unfortunately although suspend appears to work, and it does disassociate from the thread, the transaction is not removed from the internal map of all transactions:

           https://github.com/jbosstm/narayana/blob/master/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java#L1583

       

      Queries/observations:

      1. Should we suggest users (e.g. CMT) to call rollback if the tx is rolled back in a different thread rather than suspend?

      2. What if a transaction was committed in parallel? Users probably don't want to call commit again as they will get a WARN message

      3. Should we instead add something in suspend that checks the state of the transaction and calls removeTransaction if its not active? Something like (in JTA and JTS TransactionManagerImple):

      public Transaction suspend() throws javax.transaction.SystemException {

           TransactionImple tx = TransactionImple.getTransaction();

           if (tx != null)

               tx.getAtomicAction().suspend();

            if (tx.getStatus() != Status.STATUS_ACTIVE)

               tx.removeTransaction(tx);

            return tx;

      }

        • 1. Re: Issues with calling suspend to disassociate a completed transaction from the thread
          tomjenkinson

          What I meant in regards point 2 is that if a user is just trying to disassociate the TX from the thread they ideally don't want a WARN so something like suspend would be useful. That being said in an EE environment we shouldn't be seeing parallel commits happening anyway unless the user is doing something out of spec so a WARN is fair enough here.

          • 2. Re: Issues with calling suspend to disassociate a completed transaction from the thread
            tomjenkinson

            A parallel commit of TransactionImple wouldn't actually cause an issue looking at this more clearly as the thread is fine to call suspend as the initial commit on the TransactionImple cleans up the _transactions map.

             

            The issue is only if the underlying AtomicAction is completed in parallel. This is most commonly seen in the reaper so only affects the rollback case. In my opinion the impact of the second rollback is not significant (a line of warning) to warrant modifying suspend.

             

            I will leave this thread in case someone does thing it is worth modifying suspend to support clean up and avoid the line of WARN when rollback is called on a reaped transaction.