<style>
/* Changing the layout to use less space for mobiles */
@media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2) {
#email-body { min-width: 30em !important; }
#email-page { padding: 8px !important; }
#email-banner { padding: 8px 8px 0 8px !important; }
#email-avatar { margin: 1px 8px 8px 0 !important; padding: 0 !important; }
#email-fields { padding: 0 8px 8px 8px !important; }
#email-gutter { width: 0 !important; }
}
</style>
<div id="email-body">
<table id="email-wrap" align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#f0f0f0;color:#000000;width:100%;">
<tr valign="top">
<td id="email-page" style="padding:16px !important;">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#ffffff;border:1px solid #bbbbbb;color:#000000;width:100%;">
<tr valign="top">
<td bgcolor="#3e4c4e" style="background-color:#3e4c4e;color:#ffffff;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;line-height:1;"><img src="https://www.jboss.org/dms/hibernate/images/jira/jiraheader_hibernate.png" alt="" style="vertical-align:top;" /></td>
</tr><tr valign="top">
<td id="email-banner" style="padding:32px 32px 0 32px;">
<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;">
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;padding:0;">
<img id="email-avatar" src="https://hibernate.onjira.com/secure/useravatar?ownerId=brmeyer&avatarId=11140" alt="" height="48" width="48" border="0" align="left" style="padding:0;margin: 0 16px 16px 0;" />
<div id="email-action" style="padding: 0 0 8px 0;font-size:12px;line-height:18px;">
<a class="user-hover" rel="brmeyer" id="email_brmeyer" href="https://hibernate.onjira.com/secure/ViewProfile.jspa?name=brmeyer" style="color:#6c797f;">Brett Meyer</a>
commented on <img src="https://hibernate.onjira.com/images/icons/bug.gif" height="16" width="16" border="0" align="absmiddle" alt="Bug"> <a style='color:#6c797f;text-decoration:none;' href='https://hibernate.onjira.com/browse/HHH-7910'>HHH-7910</a>
</div>
<div id="email-summary" style="font-size:16px;line-height:20px;padding:2px 0 16px 0;">
<a style='color:#6c797f;text-decoration:none;' href='https://hibernate.onjira.com/browse/HHH-7910'><strong>Transaction timeout can cause non-threadsafe session access by reaper thread</strong></a>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td id="email-fields" style="padding:0 32px 32px 32px;">
<table border="0" cellpadding="0" cellspacing="0" style="padding:0;text-align:left;width:100%;" width="100%">
<tr valign="top">
<td id="email-gutter" style="width:64px;white-space:nowrap;"></td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td colspan="2" style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 16px 0;width:100%;">
<div class="comment-block" style="background-color:#edf5ff;border:1px solid #dddddd;color:#000000;padding:12px;"><blockquote>
<p>sebersole        tbh, not sure which is the best option for ultimately handing this        19:54<br/>
sebersole        seems like an exception should be thrown somewhere        19:54<br/>
sebersole        as opposed to all of a sudden the call returning, but the session just being cleared        19:55<br/>
sebersole        in which case, the method in my email response is even simplier...        19:55<br/>
smarlow        basically, I'm saying to continue clearing the session from the afterCompletion sync but also set the flag, in case we are in the middle of a entitymanager call. in which case we detect that we mutated the session        19:56<br/>
sebersole        in the "out of thread" case, we just immediately throw the exception        19:56<br/>
sebersole        well but think about the user case        19:56<br/>
sebersole        em.find(...) for example, from the user        19:56<br/>
sebersole        all of a sudden em.find(..) returns        19:56<br/>
sebersole        but        19:56<br/>
sebersole        the em is cleared        19:57<br/>
sebersole        no exception as to the rollback        19:57<br/>
sebersole        maybe we need to do both        19:58<br/>
sebersole        clear session/em and throw TransactionTimedOutException        19:59<br/>
sebersole        although, we are simply guessing that the transaction timed out        19:59<br/>
smarlow        we could build in a way to tell if the tx timedout        20:00<br/>
sebersole        how?        20:00<br/>
sebersole        you mean a jboss-specific way?        20:00<br/>
smarlow        get jbossts/tm to give JBoss AS an extension way        20:00<br/>
smarlow        like you were saying before I think, that we could use in jtaplatform        20:01<br/>
sebersole        well the problem is as they said even success can come on a different thread        20:03<br/>
smarlow        we should talk to tom again, because I wasn't clear on the success case.        20:03<br/>
smarlow        I thought the success case wasn't one we wanted to detect        20:03<br/>
smarlow        I think the success case explanation was more so that we understand why they can't always invoked afterCompletion in the application thread        20:04<br/>
sebersole        first i'd like to understand our case, our desired outcome        20:05<br/>
sebersole        we dont generally generate "extra" exceptions when a rollback comes through via the sync        20:06<br/>
sebersole        why are we doing that here?        20:06<br/>
smarlow        I think that someSessionMethod should throw an exception if we cleared the session from another thread, while someSessionMethod() was doing something        20:07<br/>
sebersole        thats really the <b>only</b> reason that detecting between (a) afterCompletion from outside app thread and (b) afterCompletion from outside app thread that hapens to be a timeout is in any way relevant        20:07<br/>
sebersole        we wont clear the session from another thread though        20:08<br/>
sebersole        you see that right?        20:09<br/>
sebersole        i mean the aftercompletion might come from that "other thread"        20:09<br/>
sebersole        but the whole idea is that we delay the clear until we get "back inside" someSessionMethod back on the app thread        20:09<br/>
sebersole        thats how you avoid the concurrent modification errors on the PC maps        20:10<br/>
smarlow        I wanted to clear the session from that "other thread" in case we aren't in someSessionMethod already        20:10<br/>
sebersole        i have yet to see that use case        20:10<br/>
smarlow        so, we let the concurrent mod happen (which I don't like but looking for the lesser evil)        20:10<br/>
sebersole        thats not the reported use case        20:10<br/>
sebersole        the reported use case was that the concurrent call to afterCompletion happens <b>during</b> call to em.find        20:11<br/>
smarlow        I agree that we can protect against the reported use case, your way        20:11<br/>
sebersole        find is someSessionMethod        20:11<br/>
smarlow        but I think my other (not reported) case, is also valid        20:12<br/>
smarlow        where the app already called someSessionMethod is doing something else for a longer time than tx timeout        20:13<br/>
sebersole        so the transaction times out after we return        20:13<br/>
smarlow        yep and the app doesn't call entitymanager.anyOthermethods        20:13<br/>
sebersole        i need to think about that one        20:13<br/>
sebersole        like i said, i dont feel overly comfortable "making up" jta exceptions        20:14<br/>
smarlow        I don't like that either        20:14<br/>
sebersole        which, yes, is exactly what TransactionTimedOutException would be        20:14<br/>
smarlow        the other path that I was thinking about, is push this case up the ee stack        20:15<br/>
smarlow        and get some better way of dealing with this        20:15<br/>
smarlow        where some other entitymanager callback is invoked from the app thread always for this case        20:15<br/>
smarlow        with coordination from jta + ee containers        20:16<br/>
sebersole        well thats possible for hibernate and jboss        20:16<br/>
sebersole        but i dont think thats going to be standard thing, certainly not for > ee7 and i doubt for ee7 even        20:16<br/>
sebersole        < ee7 i mean        20:17<br/>
smarlow        I agree with you        20:17<br/>
smarlow        it could be either an ee thing or a hibernate + jboss thing        20:17<br/>
sebersole        i understand your desire to have this "work" in jboss        20:18<br/>
sebersole        but you need to understand the need to have this "work" for Hibernate in all envs        20:18<br/>
smarlow        if we could get it to work for jboss, the other envs could do something similar (possibly)        20:18<br/>
sebersole        well the 'de facto' path is simply showing a "best alt"        20:19<br/>
sebersole        so sure, they could        20:19<br/>
sebersole        tbh, not sure i have the widest perspective though for choosing "best" here        20:20<br/>
sebersole        we should discuss with jason        20:20<br/>
smarlow        I think that we should come up with the best way without changing jboss as/jbosstm/ts but also keep in mind that if we completely hate all options, consider the jboss side path        20:20<br/>
sebersole        well tbh i think the best option might be to recognize that the afterCompletion is coming from a diff thread and just throw an error        20:21<br/>
sebersole        (and clear the session if enabled)        20:21<br/>
sebersole        not so sure we have the best "context" to do any better than that        20:22<br/>
smarlow        I suppose that the jtaplatform might be able to do better, if we could get some ee magic to help ensure the session clear does happen        20:25<br/>
sebersole        i can already make sure the clear happens        20:25<br/>
sebersole        i dont need "magic" for that        20:25<br/>
smarlow        even when no other entitymanager.someMethods are invoked after the timeout occurs?        20:26<br/>
smarlow        oh, I see, is that what you meant by "and clear the session if enabled"?        20:27<br/>
smarlow        the afterCompletion sync would clear the session if enabled?        20:27<br/>
sebersole        the afterCompletion synch would clear the session if enabled        20:27<br/>
sebersole        the delay was simply an attempt to (a) not throw an exception and (b) have the session still be usable        20:28<br/>
sebersole        not so sure thats the best outcome here        20:28</p></blockquote></div>
<div style="color:#505050;padding:4px 0 0 0;"> </div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td><!-- End #email-page -->
</tr>
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:10px;line-height:14px;padding: 0 16px 16px 16px;text-align:center;">
This message is automatically generated by JIRA.<br />
If you think it was sent incorrectly, please contact your JIRA administrators<br />
For more information on JIRA, see: <a style='color:#6c797f;' href='http://www.atlassian.com/software/jira'>http://www.atlassian.com/software/jira</a>
</td>
</tr>
</table><!-- End #email-wrap -->
</div><!-- End #email-body -->