Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

低并发导致 Tomcat 假死 #3534

Open
toint-admin opened this issue Mar 24, 2025 · 0 comments
Open

低并发导致 Tomcat 假死 #3534

toint-admin opened this issue Mar 24, 2025 · 0 comments

Comments

@toint-admin
Copy link

toint-admin commented Mar 24, 2025

环境: linux jdk21
weixin-java-cp: 4.7.0
框架配置: 一切都是默认配置, 没动过

下午五点多, 大概接收到十几个下发公众号模板消息的请求, 然后就导致 Tomcat 假死了, 没有任何异常日志.

然后我重启了服务器, 继续并发十几个请求去测试, 依旧假死.

切换到 okhttp 就正常了...


  1. 客户端: httpclient
  2. connectionRequestTimeout = -1
  3. connectTimeout=5000
  4. socketTimeout=5000

猜测: 为什么确实是存在 connectTimeout=5000socketTimeout=5000 的, 但是请求超时没有报错结束掉任务?connectionRequestTimeout 应该是从线程池获取执行线程的等待时间, 这个会一直等待, 所以导致线程被一直阻塞没有释放.

请各位大佬看看, 有没有存在类似问题的? 排查了个把月才今天运气好复现了.

hprof 文件

ID = 57 的线程 'ForkJoinPool-1-worker-1'
	jdk.internal.misc.Unsafe.park(Unsafe.java)
	java.lang.VirtualThread.parkOnCarrierThread(VirtualThread.java:675)
	java.lang.VirtualThread.park(VirtualThread.java:607)
	java.lang.System$2.parkVirtualThread(System.java:2643)
	jdk.internal.misc.VirtualThreads.park(VirtualThreads.java:54)
	java.util.concurrent.locks.LockSupport.park(LockSupport.java:369)
	java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:519)
	java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3780)
	java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3725)
	java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1712)
	org.apache.http.pool.AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:391)
	org.apache.http.pool.AbstractConnPool.access$300(AbstractConnPool.java:70)
	org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:253)
	org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:198)
	org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:306)
	org.apache.http.impl.conn.PoolingHttpClientConnectionManager$1.get(PoolingHttpClientConnectionManager.java:282)
	org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:190)
	org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
	org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
	org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
	org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
	me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor.execute(ApacheSimplePostRequestExecutor.java:42)
	me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor.execute(ApacheSimplePostRequestExecutor.java:23)
	me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl.executeInternal(BaseWxMpServiceImpl.java:475)
	jdk.internal.vm.Continuation.enterSpecial(Continuation.java)
	jdk.internal.vm.Continuation.run(Continuation.java:251)
	java.lang.VirtualThread.runContinuation(VirtualThread.java:245)
	java.lang.VirtualThread$$Lambda+0x000079d7088f4b58.run(Native method)
	java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
	java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
	java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
	java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
	java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

ID = 58 的线程 'ForkJoinPool-1-worker-2'
	jdk.internal.misc.Unsafe.park(Unsafe.java)
	java.lang.VirtualThread.parkOnCarrierThread(VirtualThread.java:675)
	java.lang.VirtualThread.park(VirtualThread.java:607)
	java.lang.System$2.parkVirtualThread(System.java:2643)
	jdk.internal.misc.VirtualThreads.park(VirtualThreads.java:54)
	java.util.concurrent.locks.LockSupport.park(LockSupport.java:369)
	java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:519)
	java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3780)
	java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3725)
	java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1712)
	org.apache.http.pool.AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:391)
	org.apache.http.pool.AbstractConnPool.access$300(AbstractConnPool.java:70)
	org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:253)
	org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:198)
	org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:306)
	org.apache.http.impl.conn.PoolingHttpClientConnectionManager$1.get(PoolingHttpClientConnectionManager.java:282)
	org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:190)
	org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
	org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
	org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
	org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
	me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor.execute(ApacheSimplePostRequestExecutor.java:42)
	me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor.execute(ApacheSimplePostRequestExecutor.java:23)
	me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl.executeInternal(BaseWxMpServiceImpl.java:475)
	jdk.internal.vm.Continuation.enterSpecial(Continuation.java)
	jdk.internal.vm.Continuation.run(Continuation.java:251)
	java.lang.VirtualThread.runContinuation(VirtualThread.java:245)
	java.lang.VirtualThread$$Lambda+0x000079d7088f4b58.run(Native method)
	java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
	java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
	java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
	java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
	java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

ID = 59 的线程 'ForkJoinPool-1-worker-3'
	jdk.internal.misc.Unsafe.park(Unsafe.java)
	java.lang.VirtualThread.parkOnCarrierThread(VirtualThread.java:675)
	java.lang.VirtualThread.park(VirtualThread.java:607)
	java.lang.System$2.parkVirtualThread(System.java:2643)
	jdk.internal.misc.VirtualThreads.park(VirtualThreads.java:54)
	java.util.concurrent.locks.LockSupport.park(LockSupport.java:369)
	java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:519)
	java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3780)
	java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3725)
	java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1712)
	org.apache.http.pool.AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:391)
	org.apache.http.pool.AbstractConnPool.access$300(AbstractConnPool.java:70)
	org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:253)
	org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:198)
	org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:306)
	org.apache.http.impl.conn.PoolingHttpClientConnectionManager$1.get(PoolingHttpClientConnectionManager.java:282)
	org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:190)
	org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
	org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
	org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
	org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
	me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor.execute(ApacheSimplePostRequestExecutor.java:42)
	me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor.execute(ApacheSimplePostRequestExecutor.java:23)
	me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl.executeInternal(BaseWxMpServiceImpl.java:475)
	jdk.internal.vm.Continuation.enterSpecial(Continuation.java)
	jdk.internal.vm.Continuation.run(Continuation.java:251)
	java.lang.VirtualThread.runContinuation(VirtualThread.java:245)
	java.lang.VirtualThread$$Lambda+0x000079d7088f4b58.run(Native method)
	java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
	java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
	java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
	java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
	java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

ID = 60 的线程 'ForkJoinPool-1-worker-4'
	jdk.internal.misc.Unsafe.park(Unsafe.java)
	java.lang.VirtualThread.parkOnCarrierThread(VirtualThread.java:675)
	java.lang.VirtualThread.park(VirtualThread.java:607)
	java.lang.System$2.parkVirtualThread(System.java:2643)
	jdk.internal.misc.VirtualThreads.park(VirtualThreads.java:54)
	java.util.concurrent.locks.LockSupport.park(LockSupport.java:369)
	java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:519)
	java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3780)
	java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3725)
	java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1712)
	org.apache.http.pool.AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:391)
	org.apache.http.pool.AbstractConnPool.access$300(AbstractConnPool.java:70)
	org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:253)
	org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:198)
	org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:306)
	org.apache.http.impl.conn.PoolingHttpClientConnectionManager$1.get(PoolingHttpClientConnectionManager.java:282)
	org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:190)
	org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
	org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
	org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
	org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
	me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor.execute(ApacheSimplePostRequestExecutor.java:42)
	me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor.execute(ApacheSimplePostRequestExecutor.java:23)
	me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl.executeInternal(BaseWxMpServiceImpl.java:475)
	jdk.internal.vm.Continuation.enterSpecial(Continuation.java)
	jdk.internal.vm.Continuation.run(Continuation.java:251)
	java.lang.VirtualThread.runContinuation(VirtualThread.java:245)
	java.lang.VirtualThread$$Lambda+0x000079d7088f4b58.run(Native method)
	java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
	java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
	java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
	java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
	java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant