connection-poolingc3p0

A checked-out resource is overdue, and will be destroyed: com.mchange.v2.c3p0.impl.NewPooledConnection@437c5a2d issue tomcat 7 c3p0


we use tomcat 7 and c3p0 as a connection pool.But since starting tomcat every 3 seconds i see many warnings : 17-Jan-2023 20:35:49.259 INFO [C3P0PooledConnectionPoolManager[identityToken->z8kfltat1hfo3gq19fe7ui|2e3d1388]-AdminTaskTimer] com.mchange.v2.resourcepool.BasicResourcePool. A checked-out resource is overdue, and will be destroyed: com.mchange.v2.c3p0.impl.NewPooledConnection@7abb733e

Here is the connection pool config: 17-Jan-2023 20:39:4.647 INFO [http-nio-8080-exec-2] com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource. Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 20, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> z8kfltat1hftvt811qptc9|2e3d1388, debugUnreturnedConnectionStackTraces -> false, description -> OLTP Connection, driverClass -> oracle.jdbc.driver.OracleDriver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> z8kfltat1hftvt811qptc9|2e3d1388, idleConnectionTestPeriod -> 300, initialPoolSize -> 3, jdbcUrl -> jdbc:oracle:thin:@192.168.0.xx:xxxx:xxxx, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 30, maxIdleTimeExcessConnections -> 30, maxPoolSize -> 500, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 50, numHelperThreads -> 3, preferredTestQuery -> SELECT 1 FROM dual, privilegeSpawnedThreads -> false, properties -> {user=, password=}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> true, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 12, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]

P.S. sorry for my english :)

I've already read every single issue posted here,tried some,but no clue.We call connection.close() in finally for each connection.


Solution

  • You have unreturnedConnectionTimeout set to 12 seconds. The message you are seeing is due to Connections not being promptly returned to the pool, triggering destruction of those Connections.

    Despite your protestation that you call Connection.close() in a finally block, either your uses of Connections are taking longer than you expect (your database operations take more than 12 seconds), or you are leaking Connections.

    c3p0 has a facility to debug apparently leaked Connections. Set debugUnreturnedConnectionStackTraces to true (only to debug, it has a performance cost), and you will see the stack traces that checked out the Connections that c3p0 times out and destroys.

    If your database operations just sometimes take more than 12 seconds, just set unreturnedConnectionTimeout to a larger value. If you find that there's a leak, you'll see where it is to fix it.

    See the docs, here.