4 Replies Latest reply on Jun 23, 2015 9:06 AM by Ondra Chaloupka

    Different behaviour of JTA and JTS when network failure occurs

    Ondra Chaloupka Apprentice

      Hi,

       

      I have another inquiring question on difference between JTA and JTS behaviour. It's case of connection failure when transaction manager is completely disconnected from outside world. The XA resouces could be e.g. two jdbc drivers of Oracle database managed with Iron Jacamar.

      The sequence would be this

       

      1. tx.commit()

      2. xar1.xa_prepare()

      3. xar2.xa_prepare() -> RMFAIL

      4. xar1.xa_rollback() ->  RMFAIL

      5. xar2.xa_rollback() -> RMFAIL

      6.a local JTA = javax.transaction.RollbackException

      6.b JTS = javax.transaction.HeuristicMixed

       

      I do understand that the OTS specification differs from local JTA case but I would like *understand* why it behaves differently. I've been a bit searching in the code of Narayana and it took me to this doubt.

      If I compare the jta XAResourceRecord [1] with jts XAResourceRecord [2] at the same time when JTA version returns FINISH_ERROR the JTS throws HeuristicHazard exception (for first prepared xa resource). Why the same situation ends with HeuristicHazard for JTS and there is no special care for JTA (in meaning that recovery manager can fix the situation on his own afterwards). In speech of code why the JTS prepared xa resource can't just throw UNKNOWN() exception [3] and ends with FINISH_ERROR [4]?

       

      I'm just curious. Thanks for any response

      Ondra

       

      [1] https://github.com/jbosstm/narayana/blob/master/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java#L408

      [2] https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/orbspecific/XAResourceRecord.java#L429

      [3] https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/orbspecific/XAResourceRecord.java#L431

      [4] https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/resources/ExtendedResourceRecord.java#L483

        • 1. Re: Different behaviour of JTA and JTS when network failure occurs
          Tom Jenkinson Master

          Hi Ondra,

           

          In terms of the difference between the JTA and JTS behaviour, remember that the behavior of the XAResources that are enlisted with the transaction are further restricted by the status' available in the OTS specification [1].


          What that means in practical terms is that there is an additional "stage" separating an XAResource from the transaction coordinator. It is worth noting that the way that Narayana is implemented means that this step is applicable whether the resource is enlisted in the same address space, distributed or of course from a heterogeneous environment to ensure consistency in behavior of the JTS/OTS.


          In real terms this means that to remain compliant with JTS/OTS the return codes from an XAResource must be translated into those that are available at the various methods defined in the OTS spec. If you look at section 2.8.2 of the resource interface (I will include here):

              interface Resource

              {

          // SNIP

            void rollback () raises (HeuristicCommit, HeuristicMixed, HeuristicHazard); 

              };

           

          You can see that unlike the more verbose options available from xa_rollback (chapter 5, XA [2]) there are limited options to return in the case of failure of a resource. In the case of RMFAIL on a prepared transaction that leads to us determining this must be dealt with as a heuristic given the more limited options available.

           

          I do hope this clarifies why JTS/OTS has altered the behavior here, if this is not so please do ask for further clarification,

          Tom

           

          [1] TRANS 1.4

          [2] http://pubs.opengroup.org/onlinepubs/009680699/toc.pdf

           

          • 2. Re: Different behaviour of JTA and JTS when network failure occurs
            Michael Musgrove Master

            Ondřej Chaloupka wrote:

             

             

            I do understand that the OTS specification differs from local JTA case but I would like *understand* why it behaves differently. I've been a bit searching in the code of Narayana and it took me to this doubt.

            If I compare the jta XAResourceRecord [1] with jts XAResourceRecord [2] at the same time when JTA version returns FINISH_ERROR the JTS throws HeuristicHazard exception (for first prepared xa resource). Why the same situation ends with HeuristicHazard for JTS and there is no special care for JTA (in meaning that recovery manager can fix the situation on his own afterwards). In speech of code why the JTS prepared xa resource can't just throw UNKNOWN() exception [3] and ends with FINISH_ERROR [4]?

             

            Remark: The code for the JTS case is running in a different JVM from the where the coordinator runs so we return the result using methods defined by the OTS resource (ie either an OTS exception or a Vote). In the JTA case the coordinator drives the resource via the XAResource interface (I say this to indicate that the coordinator is informed about what happened to the resources using different transaction models).

             

            In the JTS case the code you cite indicates that the OTS resource has already said it can commit the work (_prepared == true) but when we called rollback we got an unexpected error so we do not know what it did but we can be sure it will/has either committed or rolled back, hence the HeuristicHazard exception. But if we do not know whether or not it has said it can commit the work (_prepared == false) and we got an unexpected error on the rollback request then the best we can do is report it as a SystemException (CORBA Unknown).

            1 of 1 people found this helpful
            • 3. Re: Different behaviour of JTA and JTS when network failure occurs
              Mark Little Master

              I think Tom and Mike have provided great answers to this question.

              • 4. Re: Different behaviour of JTA and JTS when network failure occurs
                Ondra Chaloupka Apprentice

                OK. Thank you for comprehensive answer. I do now understand the reasons behind.

                Thanks