Bitbucket Server stops responding due to a Java-level deadlock
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Symptoms
Bitbucket Server becomes unresponsive.
The sequence of events that lead to this situation are not yet known and it is not easily reproducible.
Environment
The issue affects instances using Java 8.
Thread dump
Thread dumps taken during this time would show Java-level deadlocks.
The deadlock is encountered between a ClientPoller
, BlockPoller
and a few other http/s threads on the following methods:
- java.nio.channels.spi.AbstractSelectableChannel.removeKey
- java.nio.channels.spi.AbstractSelector.cancel
Cause
The deadlock is caused by the following bug in Tomcat versions 9.0.20 to 9.0.31:
64007 - A Deadlock with Poller run and cancelledKey
Affected Versions
The Bitbucket Server versions affected by this bug are:
Bitbucket Version | Embedded Tomcat Version |
---|---|
6.5.x | 9.0.21 |
6.6.x | 9.0.21 |
6.7.x | 9.0.21 |
6.8.x | 9.0.21 |
6.9.x | 9.0.21 |
6.10.0 - 6.10.2 | 9.0.27 |
7.0.0 - 7.0.1 | 9.0.30 |
Workarounds
Perform a restart of Bitbucket Server.
For multi-node Bitbucket Data Center instances, only the affected node needs to be restarted.
Fix Versions
This issue is fixed in Bitbucket Server versions 6.10.3+, 7.0.2+, 7.1.0+ or later.
These versions use Tomcat version 9.0.31+ or later.
Java 11
If an upgrade to a fix version of Bitbucket is not possible, an alternative is to use Java 11 where the issue with deadlocks is addressed (reference: Tomcat repository commit). Java 11 is installed by default with the Bitbucket 8.6.0 installer.