11 Replies Latest reply on May 26, 2015 10:10 AM by Mark Little

    Nested Transaction Support

    Rohith Thulasidas Newbie

      Dear All,



      When I was going through the nested transaction support in JbossTS - narayana 4.17.0 Final documentation , I am getting a bit confused.

      In the documentation of JbossTS it is mentioned that it supports Nested Transactions.


      http://docs.jboss.org/jbosstm/4.17.0.Final/guides/narayana-jts-development_guide/index.html#d0e465 (2.2. JBossTS and the OTS implementation, Table  2.1. - 3rd point from last)


      But in the following documentations of 4.17.0, it is mentioned that nested transactions are not supported by Jboss TS.


      http://docs.jboss.org/jbosstm/4.17.0.Final/guides/narayana-jta-development_guide/index.html  (2.1.2. Restrictions)

      http://docs.jboss.org/jbosstm/4.17.0.Final/guides/development_guide/index.html (2.3. UserTransaction)


      It seems both are contradictory. Please help me in understanding the same.



      Thanks in advance.

        • 1. Re: Nested Transaction Support
          Tom Jenkinson Master

          Hi Rohith,


          The manuals cover different parts of JBossTS. Although the core of JBossTS does indeed support nested transactions, this behavior is not exposed via the JEE JTA API. If you want to use nested transactions you could code directly against the arjuna core transaction API, here if you call AtomicAction::begin() and there is a transaction already associated with the thread it will be automatically made nested. Check out: http://docs.jboss.org/jbosstm/4.17.0.Final/guides/arjunacore-development_guide/index.html#d0e1835


          Hope that helps,


          1 of 1 people found this helpful
          • 2. Re: Nested Transaction Support
            Jonathan Halliday Master

            The engine does support them, the default configuration of the JTA layer does not, since no major XA resources managers do.


            P.S. what exactly do you mean by 'nested transaction' anyhow?


            1 of 1 people found this helpful
            • 3. Re: Nested Transaction Support
              Rohith Thulasidas Newbie

              Thanks Tom and Jonathan for quick reply.

              Now I understood that JTA layer doesn't have support for nested transactions, but the core have.


              Answering Jonathan's question

              By nested transaction I mean something which is already posted in the blog. Snippet is as follows


              "Transactions which are contained within the other transaction are said to be nested (or subtransactions), and the resulting transaction is referred to as the enclosing transaction. The enclosing transaction is sometimes referred to as the parent of a nested (or child) transaction. A hierarchical transaction structure can thus result, with the root of the hierarchy being referred to as the top-level transaction. An important difference exists between nested and top-level transactions: the effect of a nested transaction is provisional upon the commit/roll back of its enclosing transaction(s), i.e., the effects will be recovered if the enclosing transaction aborts, even if the nested transaction has committed "


              Full post is available at :




              One doubt is that, will the JTA implementation will mark the nested transaction (subtransaction as mentioned in the blog) as a part of top - level transaction.

              Once again thanks for your replies.

              • 4. Re: Nested Transaction Support
                Mark Little Master

                The JTA layer does have support for creating nested transactions if you turn it on (check the manual for the configuration option). However, as Jonathan points out, this really doesn't help you unless the resource manager(s) also supports them, which they don't.

                • 5. Re: Nested Transaction Support
                  Mark Little Master

                  Rohith Thulasidas wrote:


                  One doubt is that, will the JTA implementation will mark the nested transaction (subtransaction as mentioned in the blog) as a part of top - level transaction.

                  Once again thanks for your replies.


                  I'm not sure what you mean by this. A nested transaction will merge with the top-level transaction upon commit - that's how nested transactions are meant to behave. Unfortunately in this case, any XA resources you access within the scope of the nested transaction will not behave as though they are nested because they don't understand the context (no pun intended). This means that you won't have nested transaction semantics upon commit of the child transaction and, as importantly, upon rolling back of the parent transaction.


                  Now you can combine ArjunaCore resources (see TXJO, for instance) or your own home-grown resources, within a JTA nested transaction and get the correct semantics iff you don't touch XA. However, since JTA is really very XA specific, this isn't a general solution. Neither is it going to be portable.

                  • 6. Re: Nested Transaction Support
                    Girish Adat Newbie

                    Hi Mark,


                    We had experimented with Narayana 5.1.1, the latest, and found it to be behaving as per your comments.


                    It is allowing JTA to begin and commit nested transactions when it is configured so. But my doubt is, what is the point in supporting this, as the resources (Resource Managers) are not intimated upon prepare/commit/1pccommit/rollback/end? (But, I could see that start is being called when enlisted from the nested transaction). Even, in arjuna terminologies, I could see that the ResourceRecord.merge() is not implemented for XA in Narayana source code. Hope this is a specific decision for XA.


                    Also, it would be helpful, if you can comment on how to get the above mentioned calls to XA resources. As you had mentioned, we are working with in-house grown Resources. It looks like following XA is not a good choice for us. But, when we experimented with Atomikos in the same scenario, we could see that the above calls are reaching the Resource Managers from the Transaction Manager upon nested transaction commit.


                    Thanks and Regards, Girish Adat.

                    • 7. Re: Nested Transaction Support
                      Tom Jenkinson Master

                      Hi Girish,


                      The question regarding the use of XA was answered above (there are no-known XA resource managers that we are aware of that work with nested transactions - if you are aware of one please do let me know so I can investigate futher).


                      I think it will be better if you can create a new thread describing exactly what you would like to know.


                      I cannot comment too much as to the behaviour you have observed with Atomikos. I would expect they will have the same opinion as we that there are no-known resource managers that provide nested transaction support in their XA resource. Do you mean that with Atomikos during the inner commit you see an xa_commit propagated to the resource manager? In which case what happens when you rollback the outer transaction?


                      Maybe if you provide a small test case explaining exactly what you expect to happen I can help you further - include the resource manager name please.


                      Also, if you consult JTA 1.1 3.4.4 you can see it clearly states: "XAResource does not support nested transactions."




                      • 8. Re: Nested Transaction Support
                        Mark Little Master

                        There are some tricks you can play with XA and bqual/gtid to pretend to do nested transactions but they're really not nested transactions. I know that the Encina transaction implementation used to do this a decade or so ago.

                        • 9. Re: Nested Transaction Support
                          Mark Little Master

                          You could use the JTA API for demarcating transactions and use TXOJ for building transactional objects, but that's about as far as it goes. As you say, because XA doesn't support nesting anything more is faking it.

                          • 10. Re: Nested Transaction Support
                            Girish Adat Newbie

                            @Tom, Sorry for making some confusions out here. There was some mistake in my above post. The calls were not reaching the Resource Managers. The enlistments were getting propagated to the parent upon child commit; which was not happening in JBoss TM / Narayana. I hope both these transaction managers behaved differently as these were not specified in JTA/XA specs.


                            @Mark, I will try TXOJ with JTA for demarcation. Slight difference here is that what I am trying to play with are not Objects but resource itself. I am working more with Atomikos as well. Will get the updates in a separate post as Tom mentioned.

                            • 11. Re: Nested Transaction Support
                              Mark Little Master

                              When you say "not Objects but resources" do you mean XA resources, i.e., XAResource, or something else?