Shutting down Jira with built-in scripts may fail due to memory exhaustion

XMLWordPrintable

    • 5.02
    • 77
    • Severity 3 - Minor
    • 17

      Problem Summary

      When shutting down Jira using it's built-in scripts ('stop-jira.sh', 'shutdown.sh' or 'catalina.sh stop'), the same memory allocation settings used by Jira will be read by the auxiliary Java process (org.apache.catalina.startup.Bootstrap) spun up to execute shutdown tasks.

      If the lower boundary is set too high - sometimes equals to the upper boundary as recommended by Atlassian Support - it may not be able to execute as it will require effectively double the allocated memory available on the OS.

      Expected Behavior

      Use a lower, default memory allocation setup for the shutdown process separate to the one used by Jira's main Java process.

      Actual Behavior

      The shutdown process fails.

      Steps to Reproduce

      1. Configure the memory settings for Jira so that the lower boundary is significantly more than half the available memory on the OS;
      2. Start Jira and shut it down subsequently;

      Observe that the shutdown process will fail and throw an error similar to the following:

      Java HotSpot(TM\) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000680000000, 5368709120, 0\) failed; error='Cannot allocate memory' \(errno=12\)
      \#
      \# There is insufficient memory for the Java Runtime Environment to continue.
      \# Native memory allocation \(mmap\) failed to map 5368709120 bytes for committing reserved memory.
      \# An error report file with more information is saved as:
      \# /opt/jira/bin/hs_err_pid25290.log
      

      Workaround

      1. Access Jira's <Jira_Installation>/bin/setenv.sh file.
      2. Locate, then remove the following lines:
        JAVA_OPTS="-Xms${JVM_MINIMUM_MEMORY} -Xmx${JVM_MAXIMUM_MEMORY} ${JVM_CODE_CACHE_ARGS} ${JAVA_OPTS} ${JVM_REQUIRED_ARGS} ${DISABLE_NOTIFICATIONS} ${JVM_SUPPORT_RECOMMENDED_ARGS} ${JVM_EXTRA_ARGS} ${JIRA_HOME_MINUSD} ${START_JIRA_JAVA_OPTS}"
        
        export JAVA_OPTS
        
      3. Add the following lines to the exact place from where we removed the old ones.
        #--------------------------- Workaround for JRASERVER-35398 --------------------------------------------------------
        
        # Taking into account Order of JAVA_OPTS and CATALINA_OPTS in startup:
        #
        # We set JVM XMX 2 times:
        #  - generic, for Tomcat only through JAVA_OPTS
        #  - specific for Jira, one more time through CATALINA_OPTS
        #
        # 512MB should be enough for Tomcat stop process
        
        TOMCAT_JVM_OPTS="-Xms512m -Xmx512m"
        
        JAVA_OPTS="${JAVA_OPTS} ${TOMCAT_JVM_OPTS} ${JVM_REQUIRED_ARGS} ${DISABLE_NOTIFICATIONS} ${JVM_EXTRA_ARGS} ${JIRA_HOME_MINUSD} ${START_JIRA_JAVA_OPTS} ${JVM_CODE_CACHE_ARGS} ${JVM_SUPPORT_RECOMMENDED_ARGS}"
        
        export JAVA_OPTS
        
        JVM_OPTS_CATALINA="-Xms${JVM_MINIMUM_MEMORY} -Xmx${JVM_MAXIMUM_MEMORY}" 
        
        CATALINA_OPTS="${JVM_OPTS_CATALINA} ${CATALINA_OPTS}"
        
        export CATALINA_OPTS  
        #-------------------------------------------------------------------------------------------------------------------
        
      4. Save the changes.
      5. Restart Jira.
      6. Repeat the process on the other nodes (if any).

            Assignee:
            Bartosz Ornatowski
            Reporter:
            Sorin Sbarnea (Citrix)
            Votes:
            15 Vote for this issue
            Watchers:
            27 Start watching this issue

              Created:
              Updated:
              Resolved: