swaldman / c3p0

a mature, highly concurrent JDBC Connection pooling library, with support for caching and reuse of PreparedStatements.

Home Page:http://www.mchange.com/projects/c3p0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.sql.SQLRecoverableException: Closed Connection error in ThreadPoolAsynchronousRunner$PoolThread.run

KhushbooYadav21 opened this issue · comments

Hi @swaldman,

After upgrading c3p0 and its dependent jar -mchange, we have encountering below issue which was not present in the earlier versions we utilized.
Current version:
c3p0 -0.9.5.5
mchange -0.2.19

Previous versions:
c3p0 -0.9.1.1-1.1
mchange -0.2.11

Issue stack trace:

WARN (StatementUtils.java:60) [2024-03-13 08:48:11,368][C3P0PooledConnectionPoolManager[identityToken->1br49wab22uq2bt5fco9i|7db205ba]-HelperThread-#3] - Statement close FAILED.
java.sql.SQLRecoverableException: Closed Connection
at oracle.jdbc.driver.PhysicalConnection.needLine(PhysicalConnection.java:6295) ~[ojdbc7-12.1.0.1.jar:12.1.0.1.0]
at oracle.jdbc.driver.OracleStatement.closeOrCache(OracleStatement.java:1364) ~[ojdbc7-12.1.0.1.jar:12.1.0.1.0]
at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:1343) ~[ojdbc7-12.1.0.1.jar:12.1.0.1.0]
at oracle.jdbc.driver.OracleStatementWrapper.close(OracleStatementWrapper.java:100) ~[ojdbc7-12.1.0.1.jar:12.1.0.1.0]
at oracle.jdbc.driver.OraclePreparedStatementWrapper.close(OraclePreparedStatementWrapper.java:82) ~[ojdbc7-12.1.0.1.jar:12.1.0.1.0]
at com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:53) [mchange-commons-java-0.2.19.jar:0.2.19]
at com.mchange.v2.c3p0.stmt.GooGooStatementCache$StatementDestructionManager.synchronousDestroyStatement(GooGooStatementCache.java:943) [c3p0-0.9.5.5.jar:0.9.5.5]
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.closeAll(GooGooStatementCache.java:387) [c3p0-0.9.5.5.jar:0.9.5.5]
at com.mchange.v2.c3p0.impl.NewPooledConnection.closeAllCachedStatements(NewPooledConnection.java:781) [c3p0-0.9.5.5.jar:0.9.5.5]
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:622) [c3p0-0.9.5.5.jar:0.9.5.5]
at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:255) [c3p0-0.9.5.5.jar:0.9.5.5]
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:622) [c3p0-0.9.5.5.jar:0.9.5.5]
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1114) [c3p0-0.9.5.5.jar:0.9.5.5]
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) [mchange-commons-java-0.2.19.jar:0.2.19]
INFO (TransactionBO.java:2485) [2024-03-13 08:48:11,368][http-nio-7890-exec-733] - TransactionBO[giveBonusUsingOperator] exits...

I kindly request your attention to review and update the solution to address the aforementioned issue resulting from the recent upgrade of c3p0 and its dependent jar mchange. This problem was not observed in the previous versions we employed.

Hi. The basic issue seems to be that when c3p0 is close()ing a physical Connection -- that is, eliminating it from the pool -- it tries to close any cached statements of that Connection before destroying the Connection. Somehow you are observing these attempts failing because the physical Connection has apparently already been close()ed.

Beyond the ugly log messages, this issue is likely harmless -- it appears only when a Connection is logically removed from the application and getting cleaned up.

I don't have a good explanation of why you are seeing Connections physically closed prior to the attempt to close the Connection's cached statements.

Before working too hard to try to chase that down, is there any reason you didn't upgrade to v0.10.1, the current version of c3p0?

We had upgraded to v0.10.1, however our server didn't come up as we are suspecting compatibility issue with ojdbc8-19.22.0.0.jar. Also after upgrade will this issue resolve -java.sql.SQLRecoverableException: Closed Connection error in ThreadPoolAsynchronousRunner$PoolThread.run ?

I don't really know why you are seeing indications of Connection objects closed before c3p0 expects them to be! So I don't have much insight into whether 0.10.1 would fix the issue. There are a lot if fixes and improvements, though, betweem 0.9.5.5 and 0.10.1, so it might!

Can you provide more information regarding your experience with 0.10.1? That minor release was motivated in large part to fix issues specific to ojdbc8 (which implemented the begin/endRequest methods before JDBC 4.3 formally specified them, so they are methods of the driver's Connection implementation but not of the interface). If those fixes didn't do the job, I'd love to know the details so that I can try again.