[jbossts-issues] [JBoss JIRA] Commented: (JBTM-365) addSynchronization calls during beforeCompletion are problematic

Andrew Dinn (JIRA) jira-events at lists.jboss.org
Wed May 21 06:40:10 EDT 2008

    [ http://jira.jboss.com/jira/browse/JBTM-365?page=comments#action_12413493 ] 
Andrew Dinn commented on JBTM-365:

My apologies for being so picky. I was asking merely to check that the problem was one caused by app code, not app server code. You are right that we need to fix this as app code may rely on winning a race rather than imposing thread synchronization to make calls to addSynch safe. We need to fail gracefully if app code loses this race and modifies the list while we are copying.

If app server code is causing this to happen then the AS probably ought to be employing its own synchronization mechanism to ensure that it regulates adds from asynch threads once beforeCompletion processing has commenced -- if not then it cannot guarantee whether they will run or not. n.b. adds from AS-registered synchronizations are safe since the list is not being checked when the synch beforeCompletion method is being called.

> However isn't this a general concurrency problem since beforeCompletion may also be initiated asynchronously wrt addSynchronization during a timeout.

Not quite. The timeout code will change the transaction status causing it to avoid beforeCompletion processing and to reject addSynch calls with a rolled back exception. That said there is a synch bug raised against the status test/set code which might still allow this error to occur (see JBTM-3564 and JBTM-356). Also, there is a faint possibility that afterCompletion processing might start under a timeout while an addSynch is suspended in mid update so there are race conditions here to be dealt with.

Anyway, the upshot is that we need to lock the synchronization set when we do the add in addSynchronization and also when we check its length and, maybe, update the copy in beforeCompletion. 

> addSynchronization calls during beforeCompletion are problematic
> ----------------------------------------------------------------
>                 Key: JBTM-365
>                 URL: http://jira.jboss.com/jira/browse/JBTM-365
>             Project: JBoss Transaction Manager
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: JTA Implementation
>    Affects Versions: 4.3.0.GA
>            Reporter: Steven Hawkins
> Asynch calls to com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.addSynchronization during beforeCompletion are problematic since access to _currentRecord and _synchs is unsynchronized in addSynchronization wrt beforeCompletion.  This is similar to JBTM-188.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jbossts-issues mailing list