3 Replies Latest reply on May 10, 2011 6:04 AM by Mark Little

    Nested Transactions not being committed - Standalone

    William Burns Newbie

      Recently I have been investigating the usage of a standalone transaction manager for allowing our products to be able to do a 2 phase commit with multiple resources.  I have gotten everything to work out pretty well, however I cannot seem to get nested transactions to get committed working correctly whatsoever.  This is using the latest jbossts-jta-4.15.0.Final.zip.  I also tried with 4.13.1 but no luck.

       

      I have attached the test code I have written specifically to test this.  Basically the test starts an outer transaction, registers a resource, starts a nested transaction, registers a resource in the nested transaction, commits the nested transaction, registers another resource in the outer transaction and finally commits the outer transaction.  In the test only the first and third resources are ever ended or committed, leaving the middle resource still in an active state even though all of the transactions were committed.

       

      Here is the output of the test.

       

      1 [main] DEBUG TestNestedTransaction  - Starting outer transaction

      136 [main] DEBUG TestNestedTransaction  - Adding outer resource - 1

      139 [main] DEBUG TestNestedTransaction  - Called setTransactionTimeout transaction - 1

      140 [main] DEBUG TestNestedTransaction  - Called start transaction - 1

      141 [main] DEBUG TestNestedTransaction  - Starting nested transaction

      141 [main] DEBUG TestNestedTransaction  - Adding nested resource - 2

      141 [main] DEBUG TestNestedTransaction  - Called setTransactionTimeout transaction - 2

      141 [main] DEBUG TestNestedTransaction  - Called start transaction - 2

      141 [main] DEBUG TestNestedTransaction  - Committing nested transaction

      141 [main] DEBUG TestNestedTransaction  - Adding outer resource - 3

      142 [main] DEBUG TestNestedTransaction  - Called isSameRM transaction - 1

      142 [main] DEBUG TestNestedTransaction  - Called setTransactionTimeout transaction - 3

      142 [main] DEBUG TestNestedTransaction  - Called start transaction - 3

      142 [main] DEBUG TestNestedTransaction  - Committing outer transaction

      142 [main] DEBUG TestNestedTransaction  - Called end transaction - 1

      142 [main] DEBUG TestNestedTransaction  - Called prepare transaction - 1

      142 [main] DEBUG TestNestedTransaction  - Called end transaction - 3

      142 [main] DEBUG TestNestedTransaction  - Called prepare transaction - 3

      180 [main] DEBUG TestNestedTransaction  - Called commit transaction - 1

      180 [main] DEBUG TestNestedTransaction  - Called commit transaction - 3

       

      I have tried searching for documentation around nested transactions with jbossts-jta but couldn't really find anything really good.  I did find a blog stating about having a nested transaction aware participant (assuming that means the resource), but I don't see how that would help since the nested resource is never notified of anything.  I don't see what hookpoint I would have to tell that the resource should be added then to the outer transaction.  Would I need to pay attention to when a nested transaction is started and then log all of the resources added and when the transaction is committed finally add them to the outer one, and code for this to happen for multiple levels?  If so that seems like a lot of work, which would be a lot easier for the manager itself to do.

       

      Is there something I am missing with this?  I have tried atomikos which is another open source transaction manager and it adds the resource to the outer transaction automatically upon commit of the inner one, which is what I would expect.

       

      Also to note if I change the inner transaction to do a rollback instead of commit it is the exact same behavior.  Where as I would expect in a rollback for it to end and then rollback any registered resources before restoring the outer transaction.

       

      I have also attached a full log with all com.arjuna logging enabled.

       

      Also the reason I found this was because I was using infinispan cache and I kept getting locking due to a lock never being released due to the nested transaction not being committed or rolled back.