Generating a Thread Dump Externally

f Confluence stops responding and you can't create a thread dump within Confluence (via Support Tools), you can 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.

On this page:

Generating thread dumps on Linux

To generate a thread dump on Linux (or Solaris or other Unixes):

  1. Identify the java process that Confluence is running in.: This can be achieved by running a command similar to:

    ps -ef | grep java.
    
  2. Use the process ID from the above to generate the thread dumps:

    kill -3 <pid>

    This won't kill your server (so long as you included the "-3" option with no space in between).

    Output

    Thread dumps appear in the catalina.out file in the application directory's logs folder. Search for "thread dump" in the log file for the beginning of the dump. 

Generating thread dumps on windows  

Generating a thread dump using our scripts

We now have scripts for generating a series of thread dumps externally on Windows. Check out this BitBucket Repository for more information.

Generating a thread dump from the console

If you are not running Confluence as a service, you can generate a thread dump directly in the console. 

Click the console window and press <CTRL>+BREAK (or SHIFT+CTRL+PAUSE on some keyboards).  The thread dump will print directly to the console.

Generating a thread dump using jstack

The JDK (Java Development Kit) includes jstack, which is used for generating thread dumps.  

Note: The JRE (Java Runtime Environment) that is bundled with the Confluence installer does not include jstack. You'll need to have the full JDK installed. 

To generate a thread dump using jstack:

  1. Identify the process. Launch the task manager by, pressing Ctrl + Shift + Esc and find the Process ID of the Java (Confluence) process. (If you can't see the PID column right click a column heading in Task Manager and choose PID).
  2. 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 22668 > threaddump.txt
    

    This will create 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/JStack check 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.

You can manually generate multiple thread dumps by executing the command repeatedly, but it is 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

Thread dump analysis tools

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport