我在启动时进行了Db调用,以获取和缓存数据,接下来我要进行介绍。我曾尝试增加计算机上的内存大小,但是不走运。我一直在这里读到这是一个内存问题:Hibernate "APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!"。
这是我的连接配置:
<property name="maxPoolSize" value="100" />
<property name="initialPoolSize" value="20" />
<property name="minPoolSize" value="10" />
<property name="maxStatements" value="0" />
<property name="maxIdleTime" value="50" />
<property name="acquireIncrement" value="2" />
<property name="unreturnedConnectionTimeout" value="60" />
<!--<property name="debugUnreturnedConnectionStackTraces" value="true" /> -->
<property name="acquireRetryAttempts" value="30" />
<property name="idleConnectionTestPeriod" value="1500" />
<property name="maxConnectionAge" value="1500" />
2019-12-09 18:31:28 WARN ThreadPoolAsynchronousRunner:624 - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@97c462 -- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1bc3e0b (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@14d66f1 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1784e93 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
Pending Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@9a5764
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@2e7c1a
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@9ef600
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1312b16
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1ca6e23
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@8704ec
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@164c40a
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@11d372b
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1b6f9dd
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1ee3ce3
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@81f2c0
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@d12254
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@134ec2
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@9e7107
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@15896a6
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@38cfdb
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@57f880
Pool thread stack traces:
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(Unknown Source)
java.net.SocketInputStream.read(Unknown Source)
java.net.SocketInputStream.read(Unknown Source)
com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1647)
com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:1117)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1038)
com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(Unknown Source)
java.net.SocketInputStream.read(Unknown Source)
java.net.SocketInputStream.read(Unknown Source)
com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1647)
com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:1117)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1038)
com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(Unknown Source)
java.net.SocketInputStream.read(Unknown Source)
java.net.SocketInputStream.read(Unknown Source)
com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1647)
com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:1117)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1038)
com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)```
答案 0 :(得分:0)
尝试从数据库获取新的连接正在挂起-成功或失败都不会在很长一段时间内发生异常。在线程转储中,我们可以看到尝试获取新的连接在套接字读取时被阻止。那就是您要调试的东西:为什么会这样?
正如Nigel Savage所建议的那样,一种可能性是您在服务器端遇到了一些资源限制,可能是一些Connections,服务器超出该限制后,在完成新的Connections之前,服务器将等待并等待Connections返回。在这种情况下,更改配置以及服务器端的容量可能会解决此问题。测试此假设的一种简单方法是选择一个较小的池大小(您确信服务器可以轻松处理maxPoolSize
),然后查看APPARENT DEADLOCK
是否继续显现。如果消失,则可能是服务器端连接容量的罪魁祸首。
您可以使用maxAdministrativeTaskTime
解决此问题。但我不建议这样做。最好理解并解决该问题,而不是狂妄地迫使它消失。