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

    Nested Transactions not being committed - Standalone

    rpwburns

      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.

        • 1. Nested Transactions not being committed - Standalone
          mmusgrov

          The JTA does not support nested transactions. However if you switch to using the JTS then they are supported. This will allow you to enlist CORBA resources into the subtransaction (and you will see the prepare/commit/rollback etc methods being called on those resources). I think you will find that subtransactions are not well supported by database products.

          • 2. Nested Transactions not being committed - Standalone
            rpwburns

            I totally agree that database products don't support subtransactions that well, with possible deadlocks and other issues.  I was testing nested transactions in the scope of infinispan - which could have the same types of limitations.

             

            So from your statement it seems safe to assume that jboss/arjuna jta doesn't support nested transactions, which is fine.  I just wanted to confirm this and be aware of that limitation.

             

            Thanks for the response.

            • 3. Nested Transactions not being committed - Standalone
              marklittle

              Have you confirmed with the Infinispan team that *it* supports nested transactions? The transaction manager is only part of the equation.