我正在使用 C3p0 连接池,并且在我的服务器中观察到以下异常。
com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@ed866f -- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 1
Active Threads: 1
Active Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@995ec2 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
Pending Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@11c3ceb
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@e392ed
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@c33853
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@a6f77d
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1c25bfc
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@12534a9
com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@1a4564c
Pool thread stack traces:
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]
oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:1338)
com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:651)
com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:539)
com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234)
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470)
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
我的配置是
<property name="initialPoolSize" value="1" />
<property name="minPoolSize" value="1" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="240" />
<property name="checkoutTimeout" value="60000" />
<property name="acquireRetryAttempts" value="0" />
<property name="acquireRetryDelay" value="1000" />
<property name="debugUnreturnedConnectionStackTraces" value="true" />
<property name="unreturnedConnectionTimeout" value="300" />
<property name="numHelperThreads" value="1" />
<property name="preferredTestQuery" value="SELECT 1 FROM DUAL" />
经过一番搜索后,我发现了以下线程。 https://forum.hibernate.org/viewtopic.php?t=947246
建议禁用语句缓存以避免此问题。但在我的配置中,我没有启用语句缓存(maxStatements,maxStatementsPerConnection 默认为 0)。
请提出任何替代方案。