<div dir="ltr">Hi Tomasz,<div><br></div><div>Seems like a bug to me, there is already a question mark around it: <a href="https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java#L443">https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java#L443</a> I think you should raise a Jira and a PR would of course be appreciated.</div><div><br></div><div><div>However, I think you probably just want the CW:rollbacl() it to drop into <a href="https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java#L526">https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java#L526</a></div></div><div><br></div><div>Thanks,<br></div><div>Tom</div><div><br></div><div><div>PS: this list is kind of almost zero traffic, most people discuss development questions on the Developer sub-space over here: <a href="https://developer.jboss.org/en/jbosstm/dev/content?filterID=contentstatus%5bpublished%5d~objecttype~objecttype%5bthread%5d">https://developer.jboss.org/en/jbosstm/dev/content?filterID=contentstatus%5bpublished%5d~objecttype~objecttype%5bthread%5d</a> - thanks!</div><div><br></div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 16 August 2016 at 18:04, Tomasz Adamski <span dir="ltr">&lt;<a href="mailto:tadamski@redhat.com" target="_blank">tadamski@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have hit a race condition where the EJB interceptors and the reaper are both aborting a transaction simultaneously. If the reaper doesn&#39;t finish rollback before ejb thread enters it then the ejb thread gets INVALID_TRANSACTION (via ArjunaTransactionImple) (even though the transaction is still on the thread). ArjunaTransactionImple knows that the status is ActionStatus.ABORTED but elects to throw INVALID_TRANSACTION. By changing the code to throw TRANSACTION_ROLLEDBACK instead the EJB interceptor thread can correctly reason about the aborted transaction.<br>
<br>
More specifically, here are the two possible outcomes depending on the order in which both threads execute com.arjuna.ats.internal.jts.<wbr>ControlWrapper code:<br>
<br>
Scenario 1:<br>
* reaper executes ControlWrapper#rollback method first<br>
* server executes ControlWrapper#rollback; line _controlImpl.getImplHandle().<wbr>rollback() throws an NullPointerException as ArjunaTransactionImple has been already detached exception is caught and TransactionRolledbackException is thrown<br>
Scenario 2:<br>
* both threads enter ControlWrapper#rollback at the same time<br>
* server thread obtains ArjunaTransactionImple; transaction is in ABORTED state so InvalidTransaction exception is thrown<br>
<br>
Attempt to synchronize the code:<br>
<br>
synchronized (_controlImpl) {<br>
        _controlImpl.getImplHandle().<wbr>rollback();<br>
}<br>
<br>
on _controlImpl object doesn&#39;t work as it introduces possible deadlock to the code. Another possibility would be to check transaction status inside ArjunaTransactionImple#<wbr>rollback method and throw TransactionRolledbackException when transaction is already aborted. I have tested such fix in my branch and it fixes the initial error - TransactionRolledbackException is thrown consistently.<br>
<br>
Is such fix possible to introduce? Are there some problems that it may introduce?<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Tomasz Adamski<br>
Software Engineer<br>
JBoss by Red Hat<br>
<br>
______________________________<wbr>_________________<br>
jbossts-dev mailing list<br>
<a href="mailto:jbossts-dev@lists.jboss.org">jbossts-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/jbossts-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/jbossts-dev</a><br>
</font></span></blockquote></div><br></div>