commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Rees (JIRA)" <>
Subject [jira] Commented: (DBCP-65) [dbcp] Deadlock when evicting dbcp objects (testWhileIdle=true)
Date Fri, 29 Feb 2008 04:24:51 GMT


David Rees commented on DBCP-65:

This bug still exists in 1.2.2. I don't think that removing the prepareStatement synchronization
helps, there is still a lock-race between the Evictor and returning objects to the pool for

Here is a stack trace, I've had this happen twice in the last week on two completely different
applications (after using dbcp successfully without issue for years!):

at org.apache.commons.dbcp.AbandonedTrace.addTrace(
waiting to lock <0x0000002aa04d4be8> (a org.apache.commons.dbcp.PoolableConnection)
at org.apache.commons.dbcp.AbandonedTrace.init(
at org.apache.commons.dbcp.AbandonedTrace.<init>(
at org.apache.commons.dbcp.DelegatingStatement.<init>(
at org.apache.commons.dbcp.DelegatingConnection.createStatement(
at org.apache.commons.dbcp.PoolableConnectionFactory.validateConnection(
at org.apache.commons.dbcp.PoolableConnectionFactory.validateObject(
at org.apache.commons.pool.impl.GenericObjectPool.evict(
locked <0x0000002a9ee91bf8> (a org.apache.commons.pool.impl.GenericObjectPool)
at org.apache.commons.pool.impl.GenericObjectPool$
at java.util.TimerThread.mainLoop(
at org.apache.commons.pool.impl.GenericObjectPool.addObjectToPool(
waiting to lock <0x0000002a9ee91bf8> (a org.apache.commons.pool.impl.GenericObjectPool)
at org.apache.commons.pool.impl.GenericObjectPool.returnObject(
at org.apache.commons.dbcp.PoolableConnection.close(
locked <0x0000002aa04d4be8> (a org.apache.commons.dbcp.PoolableConnection)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(
at my.package.DbUtil.close(

In this configuration, minIdle=0, maxIdle=4, maxActive=8, testWhileIdle=true timeBetweenEvictionRunsMillis=15000

It appears that the only workaround for now to prevent this deadlock is to disable the Evictor
thread by disabling testWhileIdle.

I have two comments on DBCP-44 with other information (before I realized that this was the
bug I was hitting, though they are related).

> [dbcp] Deadlock when evicting dbcp objects (testWhileIdle=true)
> ---------------------------------------------------------------
>                 Key: DBCP-65
>                 URL:
>             Project: Commons Dbcp
>          Issue Type: Bug
>         Environment: Operating System: All
> Platform: All
>            Reporter: Wang Xianzhu
>             Fix For: 1.2.2
> The GenericKeyedObjectPool$Evictor thread has probability of deadlock with dbcp
> objects.
> For example, at a certain time, a normal user thread calls a PoolingConnection
> object's synchronized method, which in turn calls GenericKeyedObjectPool
> object's synchronzied method.
> At the same time, the evictor thread calls the GenericKeyedObjectPool object's
> synchronized method 'evict', which in turn calls the PoolingConnection object's
> synchronized method.  When testWhileIdle=true, the probability of evictor
> calling GenericKeyedObjectPool's synchronized method is much greater.
> The following is the deadlock information in the thread dump of our program
> (testWhileIdle=true):
> "Thread-106":
> 	at org.apache.commons.dbcp.AbandonedTrace.removeTrace(
> 	- waiting to lock <0x6a6b1b80> (a org.apache.commons.dbcp.PoolingConnection)
> 	at
> org.apache.commons.dbcp.PoolablePreparedStatement.passivate(
> 	at
> org.apache.commons.dbcp.PoolingConnection.passivateObject(
> 	at
> org.apache.commons.pool.impl.GenericKeyedObjectPool.evict(
> 	- locked <0x6a6b1858> (a org.apache.commons.pool.impl.GenericKeyedObjectPool)
> 	at
> org.apache.commons.pool.impl.GenericKeyedObjectPool$
> 	at
> "Thread-41":
> 	at
> org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(
> 	- waiting to lock <0x6a6b1858> (a
> org.apache.commons.pool.impl.GenericKeyedObjectPool)
> 	at
> org.apache.commons.dbcp.PoolingConnection.prepareStatement(
> 	- locked <0x6a6b1b80> (a org.apache.commons.dbcp.PoolingConnection)
> 	at
> org.apache.commons.dbcp.DelegatingConnection.prepareStatement(
> 	at
> org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(
> ...
> This problem can be worked around by setting testWhileIdle to false, although
> there is still very small possibility of deadlock.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message