Garbage Collection log settings for Bitbucket Server and Data Center 6+ when using Java version 11
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
Problem
Since Java 9, the garbage collection JVM arguments have changed, as the Unified JVM Logging has been introduced. Using GC arguments such as those supported in Java 8 such as
-Xloggc:<PATH_TO_GC_LOGS>
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintGCCause
-XX:+UseG1GC
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=5
-XX:GCLogFileSize=20M
Bitbucket will not start, as the JVM will fail with errors (example from Windows Service):
[info] [ 5516] Starting service...
[error] [ 7324] CreateJavaVM Failed
[error] [ 7324] The system cannot find the file specified.
[error] [ 5516] Failed to start Java
[error] [ 5516] ServiceStart returned 4
[info] [ 6956] Run service finished.
[info] [ 6956] Commons Daemon procrun finished
Diagnosis
Environment
AdoptOpen JDK 11
Resolution
To map old GC flags to the new ones you can reference 43 GC logging flags removed from Java 9
The following Java flags are no longer supported in Java 9 and upwards, as the Unified JVM Logging has been introduced
-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintGCCause -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=20M -Xloggc:<PATH_TO_GC_LOGS>
You must remove these flags when running Bitbucket with Java 11, otherwise Bitbucket Server will fail to start. Make sure to add the one below to keep logging GC activity in _start-webapp.sh file present in <Bitbucket-installtion-directory>/bin as a value for JVM_SUPPORT_RECOMMENDED_ARGS parameter.
-Xlog:gc*:file=<PATH_TO_GC_LOGS_Folder>/gc-%t.log:tags:time,uptime:filecount=5,filesize=20M
Example:
JVM_SUPPORT_RECOMMENDED_ARGS="-Xlog:gc*:file=<PATH_TO_GC_LOGS_folder>/gc-%t.log:tags,time,uptime,level:filecount=10,filesize=20M"
For Windows environments, the <PATH_TO_GC_LOGS> may give an error with using a drive such as D: in the path, due to the new syntax. This has been addressed in specific versions of Oracle, OpenJDK, AdoptOpenJDK.
In AdoptOpenJDK the fixed version is AdoptOpenJDK 11.0.17+8.