Jenkins controller is slow to start after upgrade

Issue

After upgrading a Jenkins controller (formerly “master”), the web UI displays the “Please wait while Jenkins is getting ready to work” message for an unusually long period of time. In the service logs you see a continual stream of entries like this:

22-Nov-2020 13:20:03.008 INFO [Jenkins initialization thread] jenkins.model.Jenkins.<init> deleting obsolete workspace /jenkins_home/workspace/my-sample-project

Environment

Resolution

This issue can occur when Jenkins tries to clean up old workspaces for jobs and branches that no longer exist. In cases where the workspace directory is very large (hundreds of GB) and/or storage performance is slow, this cleanup can take an extremely long time, and the service startup is blocked until the cleanup finishes. The workspace directory is used as a cache of SCM repositories that have been checked out previously, to help speed up builds by avoiding the need to clone the entire repo again.

Workaround

Because the workspace directory is only a cache, it is safe to delete it if the obsolete workspace cleanup process is preventing your controller from starting up in a timely way. The workaround steps are as follows:

  1. Stop the controller service.
  2. Rename JENKINS_HOME/workspace and JENKINS_HOME/cache to e.g. workspace.old and cache.old.
  3. Start the controller service again.
  4. Once service is restored, you can delete the workspace.old and cache.old directories if you wish (this is advisable as otherwise they may waste significant disk space.

Tested product/plugin versions

Branch API plugin 2.0.21 and newer.

Have more questions?

0 Comments

Please sign in to leave a comment.