The actual code works as follows, so maybe you can spot the gap in the logic?
Every transaction has a TransactionSynchronizer synchronization
that accumulates "I want to enlist these resources".
To avoid the "race" of two threads trying to enlist the same resource at the
same time,
it elects one of the threads to do any outstanding enlist requests:
| // Perform the enlistment(s)
| ArrayList unenlisted = synchronizer.getUnenlisted();
| if (unenlisted != null)
| {
| try
| {
| for (int i = 0; i < unenlisted.size(); ++i)
| {
| TransactionSynchronization sync =
(TransactionSynchronization) unenlisted.get(i);
| if (sync.enlist())
| synchronizer.addEnlisted(sync);
| }
| }
| finally
| {
| synchronizer.enlisted();
| }
| }
|
So it can't even get to that WARN unless the thread was elected as the
enlisting thread
AND there are outstanding enlistments, done here:
| synchronized ArrayList getUnenlisted()
| {
| Thread currentThread = Thread.currentThread();
| while (enlistingThread != null && enlistingThread != currentThread)
| {
| boolean interrupted = false;
| try
| {
| wait();
| }
| catch (InterruptedException e)
| {
| interrupted = true;
| }
| if (interrupted)
| currentThread.interrupt();
| }
| ArrayList result = unenlisted;
| unenlisted = null;
| if (result != null)
| enlistingThread = currentThread;
| return result;
| }
|
The WARN occurs in a "sanity check" when the finally blocks tries to say
"I am no longer the enlisting thread"
but the TransactionSynchronizer says "you weren't anyway!".
| /**
| * This thread has finished enlisting
| */
| synchronized void enlisted()
| {
| Thread currentThread = Thread.currentThread();
| if (enlistingThread == null || enlistingThread != currentThread)
| {
| log.warn("Thread " + currentThread + " not the enlisting thread "
+ enlistingThread, new Exception("STACKTRACE"));
| return;
| }
| enlistingThread = null;
| notifyAll();
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3912520#3912520
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3912520
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user