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.
Asked
Active
Viewed 5,048 times
5
1 Answers
12
Use jstack <PID>
"Thread-0" prio=10 tid=0x00002aaab01c3800 nid=0x246d runnable [0x00000000423c7000]
^ name ^ Java thread id ^ native (OS) thread id

apangin
- 92,924
- 10
- 193
- 247
-
Exactly what I was looking for, stack traces included (; – ASA Oct 24 '14 at 16:30
-
That is really great news. Just to mention if someone oversees it: the id in the thread dump is in hex while the Linux process ids are in decimal. – kap Mar 01 '21 at 10:51