-
1. Re: JTS vs. JTA transaction timeout behavior during 2PC prepare
marklittle May 11, 2016 10:02 AM (in response to ochaloup)1 of 1 people found this helpfulHave you confirmed this behaviour with the unit tests in the repo? Sounds very strange to me the way you are describing it because a timeout mandates the transaction rolls back as long as it has not got past the prepare phase.
-
2. Re: JTS vs. JTA transaction timeout behavior during 2PC prepare
ochaloup May 11, 2016 5:37 PM (in response to marklittle)Ok, I see. Till prepare phase does not end the hitting timeout time should cause that transaction is aborted.
Nope, I haven't run unit tests. But I can try. My test runs as integration ones with WFLY.
Thank you. hope looking at it at the start of the next.
-
3. Re: JTS vs. JTA transaction timeout behavior during 2PC prepare
ochaloup May 19, 2016 9:21 AM (in response to ochaloup)Ok, I've investigated a bit more on this issue and those my observations.
What I can say the transaction timeout is considered for txn reaper rolling back the transaction till time first XAResource is prepared. It means if transaction timeout occurs at the start of 2PC prepare phase where no XAResource was successfully prepared t hen transaction is aborted. If transaction timeout occurs during 2PC prepare phase when any XAResource was successfully prepared then the transaction continues to finish with commit. Could this be considered correct?
I've found out that the trouble that I've referred to was problematic as it was more complicated. I haven't realized that the core of difference is that I've used distributed transaction. One server pass to second one and transaction timeouts on the second one. Then I could see the difference between JTA and JTS where JTA commits and JTS rolls back.
After checking logs I can say that the reason why JTS rolls back is that underlying local JMS transactions timeouts before XAResource.prepare is called. Then the prepare fails with XAException.XAER_NOTA (discussed at https://developer.jboss.org/thread/269850). Meaning prepare fails and transaction abort is then called. Transaction itself tries to process with commit just as one XAResource fails it fails whole txn.
Interesting is that when JTA is play the jms broker local transaction is not aborted. It seems that subordinate transaction does not call setTransactionTimeout on XAResources it manages when JTA is used. It can be seen in log files that enlisted XAResources does not possess the timeout value which global txn has. I've created a jira on this as I consider it as an issue: JBTM-2674 If you don't agree with me, please, feel free to reject it.
My simpler additional test is following
Running on one server, behavior is the same for JTA and JTS.
- enlist test xa resource
- enlist jms xa resource
- prepare test xa resource
- before jms xa resource is prepared, transaction expires (timeout is hit)
- as this waits at the start of jms xa resource prepare method timeout occurs on jms broker local transaction as well
- jms broker local transaction is removed from broker transaction log
- jms xa resource prepare call is finished and XAER_NOTA returned
- with such error returned on XAResource.prepare transaction as whole is aborted
So far I haven't found any data inconsistency that would be caused by the current behavior.
My tests are JBoss EAP integration tests.
For looking on an unit test I would need some guide where to start. What are tests which touching this behavior.
-
4. Re: JTS vs. JTA transaction timeout behavior during 2PC prepare
marklittle May 20, 2016 9:50 AM (in response to ochaloup)One of the things we try very hard to avoid is generating heuristics. If you check the docs you'll see that any resource can autonomously commit or roll back after it has prepared, and in a distributed environment it's much more likely. I haven't checked the code but I suspect in JTS we are just trying really hard to commit the transaction after prepare irrespective of the timeout because of the inherent risk of causing a heuristic decision.
-
5. Re: JTS vs. JTA transaction timeout behavior during 2PC prepare
ochaloup May 20, 2016 11:25 AM (in response to marklittle)Ok, I see and I do understand.
The behavior is expected as commit of the transaction is preferred way.
Thank you for clarification.