Bug 53450 - Deployment of an application with 'ROOT' context hangs forever
Deployment of an application with 'ROOT' context hangs forever
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
7.0.28
PC All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-06-21 18:22 UTC by Violeta Georgieva
Modified: 2012-06-25 16:41 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Violeta Georgieva 2012-06-21 18:22:10 UTC
Hi,

The scenario is the following:
- I have running Tomcat 7.0.28
- I deploy an application with 'ROOT' context
- The deployment hangs forever. When taking a tread dump, the following is suspicious:

"localhost-startStop-2" daemon prio=6 tid=0x0000000006607800 nid=0x2560 waiting on condition [0x0000000009ebf000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000007d80f0108> (a java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:842)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1178)
        at java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:807)
        at org.apache.catalina.core.ContainerBase.removeContainerListener(ContainerBase.java:1071)
        at org.apache.catalina.core.StandardEngine$AccessLogListener.uninstall(StandardEngine.java:463)
        at org.apache.catalina.core.StandardEngine$AccessLogListener.containerEvent(StandardEngine.java:505)
        at org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1431)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:907)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)



As you can see
- A read lock is acquired at org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1425)
- Then every listener is invoked to process the container event
- Then AccessLogListener is invoked org.apache.catalina.core.StandardEngine$AccessLogListener.uninstall(StandardEngine.java:463)
- The latter causes a call for a write lock org.apache.catalina.core.ContainerBase.removeContainerListener(ContainerBase.java:1071)
- Unfortunately in the ReentrantReadWriteLock it is stated that upgrade from read to write lock is not possible
"Reentrancy also allows downgrading from the write lock to a read lock, by acquiring the write lock, then the read lock and then releasing the write lock. However, upgrading from a read lock to the write lock is not possible."

Regards
Violeta Georgieva
Comment 1 Mark Thomas 2012-06-21 18:51:00 UTC
That looks like a deadlock to me. We'll probably need a fairly quick 7.0.29 to address that. I'll take a look.
Comment 2 Mark Thomas 2012-06-21 19:58:42 UTC
Fixed in trunk and 7.0.x and will be included in 7.0.29 onwards.
Comment 3 Violeta Georgieva 2012-06-25 16:41:00 UTC
Thanks