Apache Solr open-source search software
SOLR-6705: better handling of JVM version specific options
Timothy Potter83a04af6fb01
diff --git a/solr/bin/solr b/solr/bin/solrindex 77afa860abf..dcea957a9a6 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -988,7 +988,18 @@ function launch_solr() {SOLR_ADDL_ARGS="$2"- # commented out debugging info+ # deal with Java version specific GC and other flags+ JAVA_VERSION=`echo "$(java -version 2>&1)" | grep "java version" | awk '{ print substr($3, 2, length($3)-2); }'`+ if [ "${JAVA_VERSION:0:3}" == "1.7" ]; then+ # Specific Java version hacking+ GC_TUNE="$GC_TUNE -XX:CMSFullGCsBeforeCompaction=1 -XX:CMSTriggerPermRatio=80"+ JAVA_MINOR_VERSION=${JAVA_VERSION:(-2)}+ if [[ $JAVA_MINOR_VERSION -ge 40 && $JAVA_MINOR_VERSION -le 51 ]]; then+ GC_TUNE="$GC_TUNE -XX:-UseSuperWord"+ echo -e "\nWARNING: Java version $JAVA_VERSION has known bugs with Lucene and requires the -XX:-UseSuperWord flag. Please consider upgrading your JVM.\n"+ fi+ fi+if $verbose ; thenecho -e "\nStarting Solr using the following settings:"echo -e " SOLR_SERVER_DIR = $SOLR_SERVER_DIR"@@ -1028,7 +1039,9 @@ $SOLR_HOST_ARG -Djetty.port=$SOLR_PORT \if [ "$SOLR_MODE" == "solrcloud" ]; thenIN_CLOUD_MODE=" in SolrCloud mode"fi-++ mkdir -p $SOLR_SERVER_DIR/logs+if [ "$run_in_foreground" == "true" ]; thenecho -e "\nStarting Solr$IN_CLOUD_MODE on port $SOLR_PORT from $SOLR_SERVER_DIR\n"$JAVA $SOLR_START_OPTS $SOLR_ADDL_ARGS -XX:OnOutOfMemoryError="$SOLR_TIP/bin/oom_solr.sh $SOLR_PORT" -jar start.jar@@ -1174,7 +1187,8 @@ elseecho $CLOUD_REPFACTUSER_INPUT=- read -e -p "Please choose a configuration for the $CLOUD_COLLECTION collection, available options are:\nbasic_configs, data_driven_schema_configs, or sample_techproducts_configs [data_driven_schema_configs] " USER_INPUT+ echo "Please choose a configuration for the $CLOUD_COLLECTION collection, available options are:"+ read -e -p "basic_configs, data_driven_schema_configs, or sample_techproducts_configs [data_driven_schema_configs] " USER_INPUT# trim whitespace out of the user inputCLOUD_CONFIG=`echo $USER_INPUT | tr -d ' '`diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.shindex e89e7900c08..5ca7d32648e 100644--- a/solr/bin/solr.in.sh+++ b/solr/bin/solr.in.sh@@ -19,15 +19,14 @@#SOLR_JAVA_HOME=""# Increase Java Min/Max Heap as needed to support your indexing / query needs-SOLR_JAVA_MEM="-Xms512m -Xmx512m -XX:MaxPermSize=256m -XX:PermSize=256m"+SOLR_JAVA_MEM="-Xms512m -Xmx512m"# Enable verbose GC loggingGC_LOG_OPTS="-verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails \-XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime"# These GC settings have shown to work well for a number of common Solr workloads-GC_TUNE="-XX:-UseSuperWord \--XX:NewRatio=3 \+GC_TUNE="-XX:NewRatio=3 \-XX:SurvivorRatio=4 \-XX:TargetSurvivorRatio=90 \-XX:MaxTenuringThreshold=8 \@@ -36,23 +35,11 @@ GC_TUNE="-XX:-UseSuperWord \-XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 \-XX:+CMSScavengeBeforeRemark \-XX:PretenureSizeThreshold=64m \--XX:CMSFullGCsBeforeCompaction=1 \-XX:+UseCMSInitiatingOccupancyOnly \-XX:CMSInitiatingOccupancyFraction=50 \--XX:CMSTriggerPermRatio=80 \-XX:CMSMaxAbortablePrecleanTime=6000 \-XX:+CMSParallelRemarkEnabled \--XX:+ParallelRefProcEnabled \--XX:+AggressiveOpts"--# Mac OSX and Cygwin don't seem to like the UseLargePages flag-thisOs=`uname -s`-# for now, we don't support running this script from cygwin due to problems-# like not having lsof, ps waux, curl, and awkward directory handling-if [[ "$thisOs" != "Darwin" && "${thisOs:0:6}" != "CYGWIN" ]]; then- # UseLargePages flag causes JVM crash on Mac OSX- GC_TUNE="$GC_TUNE -XX:+UseLargePages"-fi+-XX:+ParallelRefProcEnabled"# Set the ZooKeeper connection string if using an external ZooKeeper ensemble# e.g. host1:2181,host2:2181/chroot