Required Data: Jenkins Hang Issue On Linux

Issue

A specific job or your Jenkins environment hangs or responds slowly.

Required Data: Hang Issue On Linux Jenkins

This article describes how to collect the minimum required information for performance issues on a Jenkins environment so that it can be efficiently troubleshooted.

If the required data is bigger than 50 MB you will not be able to use ZenDesk to upload all the information. On this case we would like to encourage you to use our upload service in order to attach all the required information.

Environment

Automatic Data collection

This is the preferred method if you are using a product supported by the cbsupport CLI.
Current products supporting collecting performance data are:

Steps to follow are:

  1. Install and configure cbsupport following Using cbsupport CLI to collect the requested data
  2. Run cbsupport required-data performance
  3. Collect the archive generated in the working directory of cbsupport and attach it to the ticket using our upload service

Manual Data collection - Required Data check list

Ideally, your environment is configured as documented in Prepare Jenkins For Support.

  • Support bundle
  • Output of the script jenkinshangWithJstack.sh
  • GC log file for review
  • Optional (if an I/O issue is suspected): output of the script listDProcessesNativeStacks.sh

Support bundle

A support bundle from the problematic instance ideally when the issue is happening or in the worst case right after the issue is exposed. Please, follow the KB below in case you don’t know how to generate a support bundle.

Please, enable at minimum the following checks: System properties, Master Log Recorders, Garbage Collection Logs, Slow Request Records, Out Of Memory Errors, Master Heap Histogram, Deadlock Records, Thread dumps of running Pipeline builds and Thread dumps.

Find more details about the Support Bundle in What is a support-bundle and how to create one.

Output of the script jenkinshangWithJstack.sh

Depending on the type of products you have different approaches:

CloudBees Core on modern traditional platforms

This process is also valid for CloudBees Jenkins Platform (Older product) and Jenkins LTS.

Steps

1. - Check you have the required tools to run the script included in the $PATH

The script must run as the same user as Jenkins.
In the next steps we will consider this user to be named jenkins.
The following checks must be performed with this users.

The jenkinshangWithJstack.sh script collects thread dumps using either the jstack, jcmd or jattach commands.

There are 2 options here:

  • either there is a JDK installed on the machine, in which case you need to make sure that either jstack or jcmd are available either in your PATH or in the path pointed to by the JAVA_HOME variable.
  • or the machine only has a JRE installed, in which case you will need to download jattach from here.
    Once jattach is downloaded, make sure it is executable for the user jenkins and either add it to your PATH or make the variable JATTACH_HOME to the directory containing it.

The script works optimally when the following optional commands are available top, vmstat, netstat, nfsiostat, nfsstat and iostat.

2. - Download the jenkinshangWithJstack.sh script.

3. - Make the script executable

The jenkinshangWithJstack.sh script will need to be made executable by running: chmod +x jenkinshangWithJstack.sh.

4. - Get the $JENKINS_USER and $JENKINS_PID

You can retrieve the PID running ps ax | grep -i java | grep -i -e jenkins -e cloudbees | grep war | awk '{print $1}'

5. - Check that the jenkins user has permissions in the directory where jenkinshangWithJstack.sh is running

The jenkinshangWithJstack.sh script will generate data in this directory.
Alternatively you can make the script generate its output elsewhere by setting up the JENKINS_HANG_OUTPUT_DIR variable.
In this case, the jenkins user should have rights to write in JENKINS_HANG_OUTPUT_DIR.

6. - If you are experiencing a hang or a poor performance issue please execute the script while the issue is occurring:

Run the jenkinshangWithJstack.sh script as the jenkins user by running:

sudo -u jenkins sh jenkinshangWithJstack.sh $JENKINS_PID

7. - Collect the archive generated and attach it to the ticket using our upload service

Example

Running ps ax | grep -i java | grep -i -e jenkins -e cloudbees | grep war | awk '{print $1}' we get:

50946

We can now run the script, the user running Jenkins being jenkins

sudo -u jenkins sh jenkinshangWithJstack.sh 50946

You can run the script without any arguments to validate your setup.

sudo -u jenkins sh jenkinshangWithJstack.sh

Note: If the jenkinshangWithJstack.sh script does not run as expected please upload the output the script generates from the terminal window for review.

CloudBees Core on modern platforms

Steps

In addition to the process described for traditional platform, take into account the following considerations CloudBees Core on Modern: Performance Issues - High CPU / Blocked Threads.

CloudBees Jenkins Enterprise (Older product)

Steps

  1. Run cje run support-performance <TENANT> [DURATION] [FREQUENCY] as explained on How to use cje command line tools
  2. Collect the archive generated in the support/performance directory of CJE_HOME and attach it to the ticket using our upload service

GC log file for review.

If you followed Prepare Jenkins For Support then the gc logs file should be under -Xloggc:$path/gc.log Note that the slash should be adjusted for your operating system, i.e. Windows uses \

Output of the script listDProcessesNativeStacks.sh

See the What is listDProcessesNativeStacks.sh and how does it help? KB.

Have more questions?

0 Comments

Please sign in to leave a comment.