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

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

    Tom Jenkinson Master

      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;

      }