英文:
How to avoid full thread dump on shutdown?
问题
我正在运行Tomcat 8.5,每次通过控制脚本关闭Tomcat时,它都会转储线程:
完整的线程转储 OpenJDK 64位服务器 VM(25.232-b09 混合模式):
“Framework stop”#101 守护进程优先级=5 os_prio=0 tid=0x00007fb540004800 nid=0x1a05 可运行 [0x00007fa8a10ed000]
java.lang.Thread.State: RUNNABLE
...
JNI 全局引用:1348
堆
垃圾优先堆 总计 13041664K,已使用 3910741K [0x00007fb5e7800000,0x00007fb5e80031c0,0x00007fbe2c000000)
区域大小 8192K,1个年轻区(8192K),0个幸存者区(0K)
Metaspace 已使用 94108K,容量 99079K,已提交 99244K,已保留 100352K
然后需要大约2分钟才能出现下一个日志消息:
INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]
INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]
似乎转储所有线程需要相当长的时间,在正常关闭期间我实际上并不需要这么做。
我们在 EC2 Linux 实例上使用 OpenJDK 11。
控制脚本使用 catalina.sh
,它本身似乎使用关闭端口。
脚本发出的命令是 catalina.sh stop
。
在Tomcat实例上执行 kill -3
时也会出现相同的行为。
kill -15
不会显示此行为。
是否有可能在Tomcat配置或JVM参数中停用此行为?
英文:
I'm running a Tomcat 8.5 and each time I shutdown the tomcat via the control scripts, it dumps it's threads:
Full thread dump OpenJDK 64-Bit Server VM (25.232-b09 mixed mode):
"Framework stop" #101 daemon prio=5 os_prio=0 tid=0x00007fb540004800 nid=0x1a05 runnable [0x00007fa8a10ed000]
java.lang.Thread.State: RUNNABLE
...
JNI global references: 1348
Heap
garbage-first heap total 13041664K, used 3910741K [0x00007fb5e7800000, 0x00007fb5e80031c0, 0x00007fbe2c000000)
region size 8192K, 1 young (8192K), 0 survivors (0K)
Metaspace used 94108K, capacity 99079K, committed 99244K, reserved 100352K
After that it takes ~2 minutes to get to the next log message:
INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]
INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]
It seems that the dumping of all threads takes quite a while, which I really don't need during a regular shutdown.
We are utilizing OpenJDK 11 on EC2 Linux instance.
The control script is utilizing the catalina.sh
which itself seems to use the shutdown port.
catalina.sh stop
is the command issued by the scripts.
The same behavior happens when I execute kill -3
on the Tomcat instance.
kill -15
does not show this behavior.
Is there a possibility to deactivate this behavior, either in the Tomcat configuration or the JVM parameters?
答案1
得分: 3
显然,线程转储并不是原因,而是应用程序未能及时关闭的结果。
catalina.sh
有意在停止操作花费较长时间时生成线程转储。这正是为了调查关闭问题。我建议查看线程转储,而不是试图避免它。
英文:
Apparently, the thread dump is not a reason, but a consequence of the fact that the application does not shutdown in time.
catalina.sh
purposely makes a thread dump when stop operation takes long. This is exactly for investigation of shutdown issues. I'd suggest to look into the thread dump instead of trying to avoid it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论