My java process stopped responding. I tried to jstack but failed with below error.
21039: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
Then I used -F option, but "No deadlocks found."
Other info:
java version: java version
jmap: jmap
jstat: jstat
jinfo: jinfo
Can anyone help have a look and share some links on troubleshooting this kind of java "not responding" issue?
Possible reasons of
Unable to open socket fileproblem:This is obviously not your case, since
jinfo PIDworks fine.-XX:+DisableAttachMechanismoption.This can be also verified by
jinfo PID.Attach socket
/tmp/.java_pidNNNhas been deleted.There is a common practice to clean
/tmpautomatically with some scheduled script. In this case you should configure the cleanup software not to delete.java_pid*files.How to check: run
lsof -p PID | grep java_pidIf it lists a socket file, but the file does not exist, then this is exactly the described problem.
Credentials of the current user (
euid/egid) do not match the owner of the attach socket. Make sure you runjstackby the same user as JVM. Attach won't work if you runjstackby a different user, even if this user isroot./tmpdirectory of the target process is not the same as/tmpof your shell. This may happen in the following cases:jstackfrom within the same container will help.chrootenvironment. For example, LXC containers may usechroot.How to check: run
readlink -f /proc/PID/root/tmpto see if it points to/tmpor to some other directory.Current working directory of the target JVM belongs to a file system that does not allow to change permissions. CIFS and DrvFs (WSL) are examples of such file systems.
How to check: run
umask 077; touch /proc/PID/cwd/somefile.tmp, then verify that file owner is yourself, and file permissions are600.JVM is busy and cannot reach a safepoint. For instance, JVM is in the middle of long-running garbage collection.
How to check: run
kill -3 PID. JVM should print a thread dump and heap info in its console. If JVM does not dump anything, but the process consumes almost 100% CPU or shows high I/O utilization, then this looks like the described problem.JVM process is suspended.
How to check: run
ps PID. TheSTATcolumn of alive JVM process should beSl.More about the internals of jstack.
There is also
jattachproject which is a better alternative tojstack/jmap. It can automatically handle credentials issue, it works with Docker containers, supports chroot'ed JVMs and handles uncommon file systems.