Starting with 3.5.0, a new thread appears to be created each time a scheduled task executes, but is left in the WAITING state at the conclusion of the task. The overall thread count for the Nexus process increases indefinitely until the max user processes limit is reached (ulimit -u). Once this occurs, Nexus becomes mostly unresponsive.
The behavior was first observed in a regular installation of 3.5.0 on RHEL 6, where the default ulimit -u was set to 1024. Increasing the "max user processes" limit extends the time before restarting the Nexus process is required.
The issue of threads linearly increasing was reproduced using the sonatype/nexus3 Docker image on a macOS host using the following steps:
- Create and run Nexus in new Docker container with defaults:
- Login as admin, navigate to "Metrics", download "Thread dump" (result attached: 01-threads-start.txt)
- Create scheduled task, select "Advanced" for "Task frequency", and provide "* * * * * ?" for cron expression to run every second.
- Wait 30 minutes (approx. 1800 tasks run, 1800+ threads).
- Navigate to "Metrics", download "Thread dump" (result attached: 02-threads-1800-tasks-run.txt)
Thread count never exceeds 120 when following the same steps on released versions 3.3.0 - 3.4.1.