3 Replies Latest reply: Mar 12, 2010 5:26 PM by Clebert Suconic RSS

Bug on the Transaction Manager

Clebert Suconic Master

I have here what appears to be a bug on the transaction manager.

 

 

I have my user transaction (javaee user transaction) setting the timeout to 5 seconds:

 

 

         UserTransaction ut = sessionCtx.getUserTransaction();

         ut.setTransactionTimeout(5);

         ut.begin();

My test is doing some things and waiting 10 seconds:
              
               log.info("Received first message!");
               log.info("Waiting 10 seconds now!");
               try
               {
                  Thread.sleep(10000);
               }
               catch (InterruptedException ignored)
               {
               }
For some reason, the transaction is finishing ok.
I debugged this and HornetQRAXAresource is receiving and end(...Success).
The reaper thread on the Transaction manager is calling TransactionReapper.doCancellations...
a few calls later, XAResourceRecord.topLevelAbort will call this:
                    try
                    {
                         if (!_prepared)
                         {
                              if (endAssociation())
                              {
                                   _theXAResource.end(_tranID, XAResource.TMSUCCESS);
                              }
                         }
                    }

 
 

 

 

 

The only reason this is working with the current resource adapter is because the resource adapter is checking for the status on the userTransaction object on every operation. But the TransactionManager should call the proper end here with the abort status IMO.

 

 

This could be replicated by the test org.jboss.test.jca.test.TransactionActiveUnitTestCase on the HornetQ integration branch.

  • 1. Re: Bug on the Transaction Manager
    Tim Fox Master
    If you think this is a bug in the transaction manager, you should post on the transactions forum.
  • 2. Re: Bug on the Transaction Manager
    Clebert Suconic Master

    The issue is that the TM will send the rollback and disassociate the XID.

     

    later, any operation will behave as non-transacted as the TM didn't set a new XID yet.

     

    For example, on ServerSessionimpl:doSend()

     

          if (tx == null || autoCommitSends)
          {
          }
          else
          {
             routingContext.setTransaction(tx);
          }
    
          postOffice.route(msg, routingContext);
     
    

     

     

     

     

     

     

    So, we should throw an exception if a session is XA and no resource was initialized yet. (instead of silently into non-transacted mode).

     

     

    Any objections?

  • 3. Re: Bug on the Transaction Manager
    Clebert Suconic Master
          if (this.xa && tx == null)
          {
             throw new HornetQXAException(XAException.XAER_PROTO, "Invalid transaction state");
          }
          
    
    

     

     

    I am adding this check on ServerSession for send and ack. That means, if the session is XA it must be transacted (it won't act as non-transacted).

     

     

    And BTW I opened a JIRA for this: https://jira.jboss.org/jira/browse/HORNETQ-328