Apache Solr open-source search software
SOLR-8689: Fix bin/solr.cmd so it can run properly on Java 9
Uwe Schindler86f7d6779a8f
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex d2291170c67..a042d1cae94 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -296,6 +296,10 @@ Upgrading from Solr 6.x* V2 APIs are now available at /api, in addition to /v2 (which is now deprecated). Legacy APIs continue to remainavailable at /solr.+* Solr was tested and is compatible with the final release candidate of Java 9. All startup scripts+ detect Java 9 correctly and setup Garbage Collector logging. If the configuration file contains+ logging options that are no longer supported with Java 9, startup will fail.+New Features----------------------* SOLR-9857, SOLR-9858: Collect aggregated metrics from nodes and shard leaders in overseer. (ab)@@ -473,6 +477,8 @@ Bug Fixes* SOLR-11268: AtomicUpdateProcessor complains missing UpdateLog (noble, Ishan Chattopadhyaya)+* SOLR-8689: Fix bin/solr.cmd so it can run properly on Java 9 (Uwe Schindler, hossman)+Optimizations----------------------diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex ce2350b2938..8baff8008f6 100644--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -1113,14 +1113,28 @@ IF "%GC_TUNE%"=="" (-XX:-OmitStackTraceInFastThrow)-IF "%GC_LOG_OPTS%"=="" (- set GC_LOG_OPTS=-verbose:gc ^- -XX:+PrintHeapAtGC ^- -XX:+PrintGCDetails ^- -XX:+PrintGCDateStamps ^- -XX:+PrintGCTimeStamps ^- -XX:+PrintTenuringDistribution ^- -XX:+PrintGCApplicationStoppedTime+if !JAVA_MAJOR_VERSION! GEQ 9 (+ IF NOT "%GC_LOG_OPTS%"=="" (+ echo ERROR: On Java 9 you cannot set GC_LOG_OPTS, only default GC logging is available. Exiting+ GOTO :eof+ )+ set GC_LOG_OPTS="-Xlog:gc*:file=\"!SOLR_LOGS_DIR!\solr_gc.log\":time,uptime:filecount=9,filesize=20000"+) else (+ IF "%GC_LOG_OPTS%"=="" (+ rem Set defaults for Java 8+ set GC_LOG_OPTS=-verbose:gc ^+ -XX:+PrintHeapAtGC ^+ -XX:+PrintGCDetails ^+ -XX:+PrintGCDateStamps ^+ -XX:+PrintGCTimeStamps ^+ -XX:+PrintTenuringDistribution ^+ -XX:+PrintGCApplicationStoppedTime+ )+ if "%JAVA_VENDOR%" == "IBM J9" (+ set GC_LOG_OPTS=!GC_LOG_OPTS! "-Xverbosegclog:!SOLR_LOGS_DIR!\solr_gc.log" -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=9 -XX:GCLogFileSize=20M+ ) else (+ set GC_LOG_OPTS=!GC_LOG_OPTS! "-Xloggc:!SOLR_LOGS_DIR!\solr_gc.log" -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=9 -XX:GCLogFileSize=20M+ ))IF "%verbose%"=="1" (@@ -1207,26 +1221,20 @@ IF NOT EXIST "%SOLR_SERVER_DIR%\tmp" (mkdir "%SOLR_SERVER_DIR%\tmp")-IF "%JAVA_VENDOR%" == "IBM J9" (- set GCLOG_OPT="-Xverbosegclog:!SOLR_LOGS_DIR!\solr_gc.log" -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=9 -XX:GCLogFileSize=20M-) else (- set GCLOG_OPT="-Xloggc:!SOLR_LOGS_DIR!\solr_gc.log" -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=9 -XX:GCLogFileSize=20M-)-IF "%DEFAULT_CONFDIR%"=="" set "DEFAULT_CONFDIR=%SOLR_SERVER_DIR%\solr\configsets\_default\conf"IF "%FG%"=="1" (REM run solr in the foregroundtitle "Solr-%SOLR_PORT%"echo %SOLR_PORT%>"%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port- "%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% %GCLOG_OPT% ^+ "%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% ^-Dlog4j.configuration="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^-Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%" ^-Djetty.host=%SOLR_JETTY_HOST% -Djetty.port=%SOLR_PORT% -Djetty.home="%SOLR_SERVER_DIR%" ^-Djava.io.tmpdir="%SOLR_SERVER_DIR%\tmp" -jar start.jar "%SOLR_JETTY_CONFIG%" "%SOLR_JETTY_ADDL_CONFIG%") ELSE (START /B "Solr-%SOLR_PORT%" /D "%SOLR_SERVER_DIR%" ^- "%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% %GCLOG_OPT% ^+ "%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% ^-Dlog4j.configuration="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^-Dsolr.log.muteconsole ^-Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%" ^@@ -1843,8 +1851,12 @@ FOR /f "usebackq tokens=3" %%a IN (`^""%JAVA%" -version 2^>^&1 ^| findstr "versiset JAVA_VERSION_INFO=!JAVA_VERSION_INFO:"=!REM Extract the major Java version, e.g. 7, 8, 9, 10 ...- for /f "tokens=2 delims=." %%a in ("!JAVA_VERSION_INFO!") do (- set JAVA_MAJOR_VERSION=%%a+ for /f "tokens=1,2 delims=." %%a in ("!JAVA_VERSION_INFO!") do (+ if "%%a" GEQ "9" (+ set JAVA_MAJOR_VERSION=%%a+ ) else (+ set JAVA_MAJOR_VERSION=%%b+ ))REM Don't look for "_{build}" if we're on IBM J9.diff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmdindex 60712639f99..afba4f75ab5 100644--- a/solr/bin/solr.in.cmd+++ b/solr/bin/solr.in.cmd@@ -27,7 +27,9 @@ REM set SOLR_JAVA_HOME=REM Increase Java Min/Max Heap as needed to support your indexing / query needsREM set SOLR_JAVA_MEM=-Xms512m -Xmx512m-REM Enable verbose GC logging+REM Configure verbose GC logging:+REM For Java 8: if this is set, additional params will be added to specify the log file & rotation+REM For Java 9 or higher: GC_LOG_OPTS is currently not supported. If you set it, the startup script will exit with failure.REM set GC_LOG_OPTS=-verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTimeREM Various GC settings have shown to work well for a number of common Solr workloads.diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.shindex 060ece9149e..514efb1ad9d 100644--- a/solr/bin/solr.in.sh+++ b/solr/bin/solr.in.sh@@ -36,12 +36,12 @@# Enable verbose GC logging...# * If this is unset, various default options will be selected depending on which JVM version is in use-# * For java8 or lower: if this is set, additional params will be added to specify the log file & rotation-# * For java9 or higher: each included opt param that starts with '-Xlog:gc', but does not include an output-# specifier, will have a 'file' output specifier (as well as formatting & rollover options) appended,-# using the effective value of the SOLR_LOGS_DIR.+# * For Java 8: if this is set, additional params will be added to specify the log file & rotation+# * For Java 9 or higher: each included opt param that starts with '-Xlog:gc', but does not include an+# output specifier, will have a 'file' output specifier (as well as formatting & rollover options)+# appended, using the effective value of the SOLR_LOGS_DIR.#-#GC_LOG_OPTS='-Xlog:gc*' # (java9)+#GC_LOG_OPTS='-Xlog:gc*' # (Java 9+)#GC_LOG_OPTS="-verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails \# -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime"