commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sarvesh Sakalanaga (JIRA)" <>
Subject [jira] [Commented] (DBCP-398) DBCP hangs on common pool borrowObject when PoolableConnection is used and the underlying connection closed unexpectedly (connection resets/timouts)
Date Wed, 22 May 2013 17:05:21 GMT


Sarvesh Sakalanaga commented on DBCP-398:

Unfortunately it’s not that easy to write a unit test that can do this. If you are using
sql server and Data nucleus as your ORM (or any client that uses PoolableConnection) then
you can do something like this to repro the bug.

1) Take table exclusive connection lock

WAITFOR DELAY '00:06:00'  -- 6 minutes   hh:mm:ss

2) Connect to the server using the client that used PoolableConnection
3) You should see the connections when you do : SELECT * FROM sys.dm_exec_sessions
4) Execute some query on the table. EG: Select * from sds;
5) Execute "Kill XXX" (replace XXX with spid) to kill the connections. This should close the
underlyingconnection but the PoolableConnection will not be closed.
6) Call IsClosed on PoolableConnection. (BUG as it returns true);
7) Since IsClosed returns true the client will never call Close and the object is not release
to pool.

Hope this helps!

> DBCP hangs on common pool borrowObject when PoolableConnection is used and the underlying
connection closed unexpectedly (connection resets/timouts)
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>                 Key: DBCP-398
>                 URL:
>             Project: Commons Dbcp
>          Issue Type: Bug
>            Reporter: Sarvesh Sakalanaga
> The bug is in org.apache.commons.dbcp.PoolableConnection as isClosed method on this calls
super.isClosed which returns true (as DelegatingConnection::isClosed { _closed || _conn.isClosed()
}). Since PoolableConnection needs to release objects to pool even if the underlying connection
is closed the isClosed method should be overridden in this class and should return _closed.
This _closed is the delegating connection close which will be set to false even if the underlying
connection is closed (_conn.isClosed). The fix should also not throw on PoolableConnection::Close
method if underlying connection is closed as this state is a valid state and is expected.
> Also currently the way it stands the clients of PoolableConnection will/may not call
Close() as isClosed always returns true in this case.
> Below is the stack that the thread hangs on:
> ◾waiting on <0x00000007b5a50e48> (a org.apache.commons.pool.impl.GenericObjectPool$Latch)
>  at java.lang.Object.wait(
>  at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(
> ◾locked <0x00000007b5a50e48> (a org.apache.commons.pool.impl.GenericObjectPool$Latch)
>  at org.apache.commons.dbcp.PoolingDataSource.getConnection(
>  at
>  at$ManagedConnectionImpl.getConnection(
>  at$ManagedConnectionImpl.getXAResource(
>  at
>  at
>  at
>  at
>  at
>  at

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message