#125 Possible database connection leak in WrapperConnectionPoolDataSource

v1.0 (example)
closed-fixed
nobody
None
5
2014-03-24
2014-03-24
No

We are using Sybase with JConnect 4. At once we occured database connection leak problem when JConnect was down (our DBA tells physical database connection count goes to max = 2500 connections). In such situation, DataSource#getConnection still returns connection but it's initialization fails (for instance, getTransactionIsolation throws SQLException):

2014-03-20 11:53:49,912 [8b5ff]-HelperThread-#2] [WARN ] [BasicResourcePool] com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@10c93ad -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
java.sql.SQLException: JZ0SJ: Metadata accessor information was not found on this database. Please install the required tables as mentioned in the jConnect documentation.
at com.sybase.jdbc4.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc4.jdbc.MdaManager.a(Unknown Source)
at com.sybase.jdbc4.jdbc.MdaManager.<init>(Unknown Source)
at com.sybase.jdbc4.jdbc.MdaManager.<init>(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.a(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.getMDA(Unknown Source)
at com.sybase.jdbc4.tds.Tds.getIntOption(Unknown Source)
at com.sybase.jdbc4.jdbc.SybConnection.getTransactionIsolation(Unknown Source)
at com.mchange.v2.c3p0.impl.NewPooledConnection.<init>(NewPooledConnection.java:125)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:211)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)

It seems that the problem place is WrapperConnectionPoolDataSource#getPooledConnection: why not to close connection (Connection conn = nds.getConnection()) in try-catch-finally block if new NewPooledConnection(...) throws SQLException?

Discussion

  • Steve Waldman

    Steve Waldman - 2014-03-24

    hi,

    thanks for the report! this is a duplicate, though. the issue was resolved as of c3p0-0.9.5-pre5. please try the latest c3p0-0.9.5 prerelease (currently -pre7). hopefully you won't experience this sort of problem.

    thanks again!

     
  • Steve Waldman

    Steve Waldman - 2014-03-24
    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks