Confluence 5.8 has reached end of life
Check out the [latest version] of the documentation
If Confluence stops responding and you cannot access its integrated Generate Thread Dump feature, it is possible to create thread dumps outside the application. External thread dumps are also useful if you require information on locks being held or waited upon by threads.
Take Multiple Thread Dumps
Typically you'll want to take several dumps about 10 seconds apart, in which case you can generate several dumps and output the stack traces to a single file as follows:
Generating a Thread Dump on Linux, including Solaris and other Unixes
Identify the java process that Confluence is running in.: This can be achieved by running a command similar to:
ps -ef | grep java.
Use the process ID from the above to generate the thread dumps:
kill -3 <pid>
This will not kill your server (so long as you included the "-3" option, no space in between).
Output
Thread dumps appear in the catalina.out file in the application directory's logs folder. You can search for the term "thread dump" in the log file for the beginning of the dump. Submit this along with the atlassian-confluence.log in your support ticket.
Generating Thread Dumps on Windows
We now have scripts for generating thread dumps externally on Windows. Please see this BitBucket Repository for more information!
From the console
If you are running Confluence through a console, rather than as a service, you can click on the console and press <CTRL>+BREAK
Using jstack
The JDK ships with a tool named jstack for generating thread dumps.
- Identify the process. Launch the task manager by, pressing
Ctrl + Shift + Escand find the Process ID of the Java (Confluence) process. You may need to add the PID column usingView->Select Columns ... Run jstack <pid> to Capture a Single Thread Dump. This command will take one thread dump of the process id <pid>, in this case the pid is 22668:
adam@track:~$ jstack -l 22668 > threaddump.txt
This will output a file called threaddump.txt to your current directory.
Common issues with jstack:
- You must run jstack as the same user that is running Confluence
- If the jstack executable is not in your $PATH, then please look for it in your <JDK_HOME>/bin directory
- If you receive
java.lang.NoClassDefFoundError: sun/tools/jstack/JStackcheck that tools.jar is present in your JDK's lib directory. If it is not, download a full version of the JDK. - If you see the following message: 'Not enough storage is available to process this command,' see this article.
- If you get the error "Not enough storage is available to process this command", download the 'psexec' utility from here, then run the following command using:
psexec -s jstack <pid> >> threaddumps.txt
Output
Thread dumps appear in the catalina.out file in the application directory's logs folder. You can search for the term "thread dump" in the log file for the beginning of the dump. Submit this along with the atlassian-confluence.log in your support ticket.
Often Support may ask you to generate a sequence of thread dumps over a short period, so that they can compare what each dump contains and to look for any long running threads that could be the cause of the performance issue. While manually running kill -3 from the command repeatedly will work, it's often easier to use a small script to automate the process. Here's an example that you can adapt to run on your server:
for i in `seq 1 10` ; do
echo ${i}
your/path/to/jstack `ps aux | grep java | grep confluence | grep -v grep | awk '{print $2}'` >> threaddump.log
sleep 10
done