gpt4 book ai didi

Java 表观死锁

转载 作者:行者123 更新时间:2023-12-01 19:31:05 24 4
gpt4 key购买 nike

我在启动时进行了一个 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)```

最佳答案

从数据库获取新连接的尝试被挂​​起——在很长一段时间内既不成功也不失败,并出现异常。在线程转储中,我们可以看到获取新连接的尝试在套接字读取上被阻塞。这就是您想要调试的内容:为什么会发生这种情况?

正如 Nigel Savage 所建议的,一种可能性是您已经达到了服务器端的某些资源限制,可能是连接数超出了该限制,服务器会在完成新连接之前阻塞并等待连接返回。如果是这种情况,更改服务器端的配置和容量可能可以解决问题。测试此假设的一个简单方法是选择一个较小的池大小(您确定服务器可以轻松处理的 maxPoolSize),并查看明显的死锁是否继续存在显现。如果它消失,则可能是服务器端连接容量造成的。

您可以使用 maxAdministrativeTaskTime 解决此问题。但我不建议这样做。最好是理解并解决问题,而不是笨拙地强制它消失。

关于Java 表观死锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59259001/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com