1 Reply Latest reply on May 23, 2006 11:49 AM by Mark Little

    JTA recovery of XA resources (crash during prepare)

    Paul Robinson Master

      Hello,

      I am now testing XA recovery in JBossTS (in JTA mode).

      I have created a test XA resource that simply logs its actions. I can give the resource a name so that when it logs it identifies itself. I can also choose when (if at all) I want it to crash (Runtime.getRuntime().halt(0)).

      I am investigating what happens when a resource fails during prepare. I have three resources, (A,B,C). I enlist them in order and configure resource C to crash at the beginning of its prepare method.

      This is the output when no resource crashes

      A: start
      B: start
      C: start
      A: end
      A: prepare (0)
      B: end
      B: prepare (0)
      C: end
      C: prepare (0)
      A: serializing
      B: serializing
      C: serializing
      A: commit
      B: commit
      C: commit


      And this is the output when C crashes during the prepare method:

      A: start
      B: start
      C: start
      A: end
      A: prepare (0)
      B: end
      B: prepare (0)
      C: end
      C: CRASH!


      So, A and B have prepared whilst C hasn't. The coordinator logs once all the resources have successfully prepared. As this doesn't happen, nothing is written to the log and thus no recovery occurs. I think this is OK so far, as presumed abort is in operation and (A,B) does not need to be told to rollback by the coordinator.

      However, this does rely on the resources (A,B) being able to ask the coordinator what the outcome of the transaction was. My question is, without JTS, how can the XA resource query the coordinator in a non-implementation specific manor (I wouldn't expect the resource to know that it was being coordinated by JBossTS)?

      Thanks,

      Paul.


        • 1. Re: JTA recovery of XA resources (crash during prepare)
          Mark Little Master

          It can't. Recovery isn't standardised except in JTS and WS-T. In the land of pure XA, then you are pretty much on your own and it is implementation specific. XA does not require resources to query coordinators. Some implementations don't: they timeout after some period and make an autonomous choice (usually to roll back). Heuristics could obviously occur then, but that's an implementation choice.