Generating thread dumps with kill -3


Trying to generate thread dumps using kill -3 but can not see where the dumps are routed . If some one is using JRE instead JDK then jstack will not be available so there is no other option than kill -3 .

Be sure the -Xrs JVM option is not being used, as it causes SIGQUIT and SIGWAITING signals to be ignored. Running kill -3 sends a SIGQUIT signal to the JVM, so using this option will cause kill -3 to be ignored.

I have tried to generate thread dump using kill -3 and I am able to generate it successfully.

Thread dumps will be in the file where stdout is redirected or in console output.

[aipatil@aipatil bin]$ ps -ef|grep java
aipatil  29150 29071 47 00:21 pts/0    00:00:10 java -D[Standalone] -server -verbose:gc -Xloggc:/home/aipatil/Downloads/Jboss_EAP_Binaries/jboss-eap-7.2.0/jboss-eap-7.2/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/home/aipatil/Downloads/Jboss_EAP_Binaries/jboss-eap-7.2.0/jboss-eap-7.2/standalone/log/server.log -Dlogging.configuration=file:/home/aipatil/Downloads/Jboss_EAP_Binaries/jboss-eap-7.2.0/jboss-eap-7.2/standalone/configuration/ -jar /home/aipatil/Downloads/Jboss_EAP_Binaries/jboss-eap-7.2.0/jboss-eap-7.2/jboss-modules.jar -mp /home/aipatil/Downloads/Jboss_EAP_Binaries/jboss-eap-7.2.0/jboss-eap-7.2/modules -Djboss.home.dir=/home/aipatil/Downloads/Jboss_EAP_Binaries/jboss-eap-7.2.0/jboss-eap-7.2 -Djboss.server.base.dir=/home/aipatil/Downloads/Jboss_EAP_Binaries/jboss-eap-7.2.0/jboss-eap-7.2/standalone
aipatil  29330 28805  0 00:22 pts/1    00:00:00 grep --color=auto java

[aipatil@aipatil bin]$ kill -3 29150


2021-04-26 00:23:56
Full thread dump OpenJDK 64-Bit Server VM (25.242-b08 mixed mode):

"ServerService Thread Pool -- 74" #130 prio=5 os_prio=0 tid=0x0000556752e7f000 nid=0x7299 waiting on condition [0x00007f78ee684000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000fca10198> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(
    at java.util.concurrent.ThreadPoolExecutor.getTask(
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$

"ServerService Thread Pool -- 73" #129 prio=5 os_prio=0 tid=0x000055674f12d000 nid=0x727a waiting on condition [0x00007f78f7b86000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)

OpenJDK / Sun JDK
Use jps -lv to find the Java process ID for issuing kill -QUIT or kill -3.
Be sure the -Xrs JVM option is not being used, as it causes SIGQUIT and SIGWAITING signals to be ignored. Running kill -3 sends a SIGQUIT signal to the JVM, so using this option will cause kill -3 to be ignored. 

If using OpenJDK or Sun JDK 1.6 or later, using jstack is an option. This is useful when redirecting standard out to a file is problematic for some reason (e.g. it is not desirable to restart the JVM just to redirect standard out). Execute the following, passing in the Java process ID:

jstack -l JAVA_PID > jstack.out
Note the process ID number of the Java process (e.g. using top, a grep on ps -axw, etc.) and send a QUIT signal to the process with the kill -QUIT or kill -3 command 1. For example:

kill -3 JAVA_PID 
thread details will be routed to the file where the standard output is redirected .refer startup script . if started from console it may be written to host controller log .

JBoss EAP Parameter
Use the below command to start JBoss instance and then use kill -3 to generate the thread dumps.
If the Java application is started with a service script that logs console output, the thread dumps will be in the console log. Otherwise, redirect stdout to a file on startup.

nohup $JBOSS_HOME/bin/ -c  yourinstancename $JBOSS_OPTS >> console-$(date +%Y%m%d).out  2>&1 < /dev/null & kill -3 JAVA_PID 
This will redirect your output/dump to the file console specified in the above command.

in the above case refer console-$(date +%Y%m%d).out .better trim the file before trying kill -3 using >console-$(date +%Y%m%d).out
NOW VERIFY console-$(date +%Y%m%d).out 

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *