You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by amit shah <am...@gmail.com> on 2013/03/28 13:27:21 UTC

Tomcat JDBC Connection Pool - Deadlock

Hello,
         I am using the tomcat jdbc connection pool independently in my web
application which is deployed on glassfish web server. While performing a
database operation, our application goes into a deadlock state. The two
threads involved in the deadlock have the below traces (from a thread dump)

"thread1" Id=534 WAITING on
java.util.concurrent.locks.ReentrantReadWriteLock$FairSync@184ffd83 owned
by "thread2" Id=529
at sun.misc.Unsafe.park(Native Method)
 -  waiting on
java.util.concurrent.locks.ReentrantReadWriteLock$FairSync@184ffd83
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
 at
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
at
java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:945)
 at
com.sun.ejb.containers.CMCSingletonContainer._getContext(CMCSingletonContainer.java:142)
at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2528)
 ...

Number of locked synchronizers = 1
- java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@3f88774b

, "thread2" Id=529 WAITING on
java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@3f88774bowned
by "thread1" Id=534
at sun.misc.Unsafe.park(Native Method)
 -  waiting on
java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@3f88774b
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
 at
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
at
java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:945)
 at
org.apache.tomcat.jdbc.pool.PooledConnection.lock(PooledConnection.java:609)
at
org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:752)
 ...

Number of locked synchronizers = 1
- java.util.concurrent.locks.ReentrantReadWriteLock$FairSync@184ffd83


Having a look at the source code for both
<http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_34/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java>of
these <http://grepcode.com/file/repo1.maven.org/maven2/org.glassfish.ejb/ejb-container/3.1.1/com/sun/ejb/containers/CMCSingletonContainer.java?av=f>
I
see different lock instances but still the dump indicates that they are the
same. Any idea on how can the java.util.lock instances be the same?

Thanks,
Amit.

RE: Tomcat JDBC Connection Pool - Deadlock

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: amit shah [mailto:amits.84@gmail.com] 
> Subject: Re: Tomcat JDBC Connection Pool - Deadlock

> I copied the dev group too since it involved technical details (thread
> dumps, source code etc). Sorry if that sounds incorrect.

It was incorrect, as is your top-posting.  Don't do either.

> The traces I added are not incomplete.

Clearly they are incomplete, as evidenced by the ellipses after both fragments.  Use a more appropriate mechanism:

http://wiki.apache.org/tomcat/HowTo#How_do_I_obtain_a_thread_dump_of_my_running_webapp_.3F

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat JDBC Connection Pool - Deadlock

Posted by amit shah <am...@gmail.com>.
I copied the dev group too since it involved technical details (thread
dumps, source code etc). Sorry if that sounds incorrect.

The traces I added are not incomplete. They are the ones we generated
through the jmx api
- ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);


On Thu, Mar 28, 2013 at 6:21 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: amit shah [mailto:amits.84@gmail.com]
> > To: Tomcat Users List; dev@tomcat.apache.org
>
> Do not cross-post.  This belongs only on the users list.  Read (and
> follow) the mailing list usage rules.
>
> > Subject: Tomcat JDBC Connection Pool - Deadlock
>
> > The two threads involved in the deadlock have the below traces
> > (from a thread dump)
>
> You'll need to show the complete traces for both threads, not just the
> tail ends.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail and
> its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: Tomcat JDBC Connection Pool - Deadlock

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: amit shah [mailto:amits.84@gmail.com] 
> To: Tomcat Users List; dev@tomcat.apache.org

Do not cross-post.  This belongs only on the users list.  Read (and follow) the mailing list usage rules.

> Subject: Tomcat JDBC Connection Pool - Deadlock

> The two threads involved in the deadlock have the below traces 
> (from a thread dump)

You'll need to show the complete traces for both threads, not just the tail ends.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat JDBC Connection Pool - Deadlock

Posted by Daniel Mikusa <dm...@vmware.com>.
On Mar 28, 2013, at 8:27 AM, amit shah wrote:

> Hello,
>         I am using the tomcat jdbc connection pool independently in my web

Because you are using this independently you are going to need to tell us the version of the connection pool that you have included with your application.  Also, a code snippet that shows how you setup the connection pool, we need to see what options that you have used.

> application which is deployed on glassfish web server. While performing a
> database operation,

What specifically are you doing in the application?  Can you include a code snippet?  In particular, we'd want to see how you are getting a connection, how its being used and how you are returning it to the pool.

> our application goes into a deadlock state.

How are you determining this?  What is the behavior that you see with your application?

Dan



> The two threads involved in the deadlock have the below traces (from a thread dump)
> 
> "thread1" Id=534 WAITING on
> java.util.concurrent.locks.ReentrantReadWriteLock$FairSync@184ffd83 owned
> by "thread2" Id=529
> at sun.misc.Unsafe.park(Native Method)
> -  waiting on
> java.util.concurrent.locks.ReentrantReadWriteLock$FairSync@184ffd83
> at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
> at
> java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:945)
> at
> com.sun.ejb.containers.CMCSingletonContainer._getContext(CMCSingletonContainer.java:142)
> at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2528)
> ...
> 
> Number of locked synchronizers = 1
> - java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@3f88774b
> 
> , "thread2" Id=529 WAITING on
> java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@3f88774bowned
> by "thread1" Id=534
> at sun.misc.Unsafe.park(Native Method)
> -  waiting on
> java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@3f88774b
> at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
> at
> java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
> at
> java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:945)
> at
> org.apache.tomcat.jdbc.pool.PooledConnection.lock(PooledConnection.java:609)
> at
> org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:752)
> ...
> 
> Number of locked synchronizers = 1
> - java.util.concurrent.locks.ReentrantReadWriteLock$FairSync@184ffd83
> 
> 
> Having a look at the source code for both
> <http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_34/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java>of
> these <http://grepcode.com/file/repo1.maven.org/maven2/org.glassfish.ejb/ejb-container/3.1.1/com/sun/ejb/containers/CMCSingletonContainer.java?av=f>
> I
> see different lock instances but still the dump indicates that they are the
> same. Any idea on how can the java.util.lock instances be the same?
> 
> Thanks,
> Amit.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org