如何通过已知的PID / TID获取JVM线程名称/ id [英] How to obtain the JVM thread name/id through the known PID/TID

查看:2188
本文介绍了如何通过已知的PID / TID获取JVM线程名称/ id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天我们在Debian上运行的tomcat 6服务器出现了一个奇怪的问题:我们有第二次长时间冻结/中断,长度随着时间的推移而增加。在冻结期间,我们所有的独立网络应用程序都没有响应。中断具有非常高的规律性,在一小时的过程中,中断阶段变得比活动阶段更长,直到我们重新启动解决问题的服务器。现在我们想知道它是什么或找到解决方案,以找出它再次发生的情况!


在每个停机阶段,24个核心中的一个100%被其中一个使用tomcat线程,所以我们假设线程正在做的是冻结整个tomcat。遗憾的是,我们不知道那个主题是在做什么。今天我研究了一个获得java线程TID的解决方案,我发现了一个很棒的解决方案:获取Linux中Java线程的线程ID


将它放入我们广泛的日志文件条目中并找到JVM线程很容易,但是如果它是一个不完全在我们控制之下的线程?那么拥有同步的TID / Java-Thread-ID快照会有什么烦恼呢?这导致了我的核心问题:

有没有办法从已知的Linux TID获取JVM线程名称/ id?

我的希望很小,但是也许有一个对JVM的交叉进程调用或我还没有考虑过的另一个想法。


我们在该服务器上运行了Yourkit profiler,但在中断阶段它无法进行记录任何东西,所以我们找不到有问题的线程。

Yesterday we had a weird problem with our tomcat 6 server which is running on Debian: We had second long freezes/outages that increased in length over time. In the frozen periods all our independent web apps were unresponsive. The outages had a very high regularity and over the course of one hour the outage phases became longer than the active phases, until we restarted the server which solved the problem. Now we want to find out what it was or find a solution to find out what it is if it happens again!

During each outage phase one of the 24 cores was used 100% by one of the tomcat threads, so we assume whatever that thread was doing was freezing the whole tomcat. Sadly we have no idea what that thread was working on. Today I researched a solution to get the TID of a java thread and I found a wonderful solution: Obtaining the thread ID for Java threads in Linux .

Putting it in our extensive log file entries and finding the JVM thread would be easy enough, but what if it's a thread that isn't exactly under our control? And what about the annoyance of having a synced TID / Java-Thread-ID snapshot? This leads to my core question:

Is there a way to get the JVM Thread name/id from a known Linux TID?

My hopes are small, but maybe there is a cross process call to the JVM or another idea I haven't considered yet.

We have the Yourkit profiler running on that server, but during the outage phases it wasn't able to record anything, so we couldn't find the offending thread.

推荐答案

使用 jstack< PID> ;

"Thread-0" prio=10 tid=0x00002aaab01c3800 nid=0x246d runnable [0x00000000423c7000]
    ^ name             ^ Java thread id       ^ native (OS) thread id

这篇关于如何通过已知的PID / TID获取JVM线程名称/ id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆