Is there a replacement for the garbage collection JVM args in Java 11

XMLWordPrintable

    • 1
    • 1

      As a Jira admin, I want to have an easier way to set the flag -XX:UseG1GC when using Java 11

      Problem Definition

      Java 11 no longer supports some GC parameters that were supported in Java 8, such as:

      -XX:+PrintGCDetails
      -XX:+PrintGCDateStamps
      -XX:+PrintGCTimeStamps
      -XX:+PrintGCCause
      -XX:+UseGCLogFileRotation
      -XX:NumberOfGCLogFiles=5
      -XX:GCLogFileSize=20M
      -Xloggc:<PATH_TO_GC_LOGS>
      

      Because of that, we now have the script JIRA_INSTALL/bin/set-gc-params.sh to detect the currently used Java version and apply the correct flags. However, when using Java 11 we set -XX:+UseParallelGC by default:

      JIRA_INSTALL/bin/set-gc-params.sh
      #!/bin/sh
      
      GC_JVM_PARAMETERS=""
      
      if [ $java_version -ge 9 ]
      then
          # In Java 9, GC logging has been re-implemented using the Unified GC logging framework.
          # See http://openjdk.java.net/jeps/158 or https://docs.oracle.com/javase/10/jrockit-hotspot/logging.htm
          GC_JVM_PARAMETERS="-Xlog:gc*:file=$LOGBASEABS/logs/atlassian-jira-gc-%t.log:time,uptime:filecount=5,filesize=20M ${GC_JVM_PARAMETERS}"
          GC_JVM_PARAMETERS="-XX:+UseParallelGC ${GC_JVM_PARAMETERS}"
      else
          # Set the JVM arguments used to start JIRA. For a description of the options, see
          # http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
      
          #-----------------------------------------------------------------------------------
          # This allows us to actually debug GC related issues by correlating timestamps
          # with other parts of the application logs.
          #-----------------------------------------------------------------------------------
          GC_JVM_PARAMETERS="-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintGCCause ${GC_JVM_PARAMETERS}"
          GC_JVM_PARAMETERS="-Xloggc:$LOGBASEABS/logs/atlassian-jira-gc-%t.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=20M ${GC_JVM_PARAMETERS}"
      fi
      
      CATALINA_OPTS="${GC_JVM_PARAMETERS} ${CATALINA_OPTS}"
      export CATALINA_OPTS
      

      If -XX:+UseG1GC is set, the JVM will fail to start with the following error:

      Error occurred during initialization of VM
      Multiple garbage collectors selected
      

      Suggested Solutions

      • Check if another garbage collector has been specified, and don't set -XX:+UseParallelGC in this case.
      • No longer set -XX:+UseParallelGC by default.

      Workaround

      1. Manually remove the flag -XX:+UseParallelGC from JIRA_INSTALL/bin/set-gc-params.sh.
      2. Follow the steps in the KB article Setting properties and options on startup to add the following Java flag to JVM_SUPPORT_RECOMMENDED_ARGS in the file JIRA_INSTALL/bin/setenv.sh:
        -XX:+UseG1GC
        

            Assignee:
            Artur Gniadzik
            Reporter:
            Irfan Md
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: