Skip to content

Commit

Permalink
Merge remote-tracking branch 'apache/main' into hostname-check-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HoustonPutman committed Sep 12, 2023
2 parents e74f613 + b98d936 commit d16ae0e
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 97 deletions.
5 changes: 5 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Improvements
This will enable client and server hostName check settings to be governed by the same environment variable.
If users want separate client/server settings, they can manually override the solr.jetty.ssl.sniHostCheck option in SOLR_OPTS. (Houston Putman)

* SOLR-16970: SOLR_OPTS is now able to override options set by the Solr control scripts, "bin/solr" and "bin/solr.cmd". (Houston Putman)


Optimizations
---------------------
Expand Down Expand Up @@ -166,6 +168,9 @@ Bug Fixes

* SOLR-16044: SlowRequest logging is no longer disabled if SolrCore logger set to ERROR (janhoy, hossman)

* SOLR-16415: asyncId must not have '/'; enforce this. Enhance ZK cleanup to process directories
instead of fail. (David Smiley, Paul McArthur)

* SOLR-16963: The "solr.jetty.ssl.verifyClientHostName" sysProp and "SOLR_SSL_CLIENT_HOSTNAME_VERIFICATION" envVar have been fixed,
and the setting once again tells the server to check the originating client hostname against the client certificate when doing mTLS. (Houston Putman, Tomás Fernández Löbbe)

Expand Down
92 changes: 49 additions & 43 deletions solr/bin/solr
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ function jetty_port() {
function run_tool() {

# shellcheck disable=SC2086
"$JAVA" ${SOLR_TOOL_OPTS:-} $SOLR_SSL_OPTS $AUTHC_OPTS ${SOLR_ZK_CREDS_AND_ACLS:-} -Dsolr.install.dir="$SOLR_TIP" \
"$JAVA" $SOLR_SSL_OPTS $AUTHC_OPTS ${SOLR_ZK_CREDS_AND_ACLS:-} ${SOLR_TOOL_OPTS:-} -Dsolr.install.dir="$SOLR_TIP" \
-Dlog4j.configurationFile="$DEFAULT_SERVER_DIR/resources/log4j2-console.xml" \
-classpath "$DEFAULT_SERVER_DIR/solr-webapp/webapp/WEB-INF/lib/*:$DEFAULT_SERVER_DIR/lib/ext/*:$DEFAULT_SERVER_DIR/lib/*" \
org.apache.solr.cli.SolrCLI "$@"
Expand Down Expand Up @@ -742,7 +742,7 @@ function stop_solr() {
if [ -n "$SOLR_PID" ]; then
echo -e "Sending stop command to Solr running on port $SOLR_PORT ... waiting up to $SOLR_STOP_WAIT seconds to allow Jetty process $SOLR_PID to stop gracefully."
# shellcheck disable=SC2086
"$JAVA" ${SOLR_TOOL_OPTS:-} $SOLR_SSL_OPTS $AUTHC_OPTS -jar "$DIR/start.jar" "STOP.PORT=$THIS_STOP_PORT" "STOP.KEY=$STOP_KEY" --stop || true
"$JAVA" $SOLR_SSL_OPTS $AUTHC_OPTS ${SOLR_TOOL_OPTS:-} -jar "$DIR/start.jar" "STOP.PORT=$THIS_STOP_PORT" "STOP.KEY=$STOP_KEY" --stop || true
(loops=0
while true
do
Expand Down Expand Up @@ -1222,6 +1222,7 @@ fi
FG="false"
FORCE=false
SOLR_OPTS=(${SOLR_OPTS:-})
SCRIPT_SOLR_OPTS=()
PASS_TO_RUN_EXAMPLE=()

if [ $# -gt 0 ]; then
Expand Down Expand Up @@ -1370,6 +1371,7 @@ if [ $# -gt 0 ]; then
break # out-of-args, stop looping
elif [ "${1:0:2}" == "-D" ]; then
# pass thru any opts that begin with -D (java system props)
# These should go to the end of SOLR_OPTS, as they should override everything else
SOLR_OPTS+=("$1")
PASS_TO_RUN_EXAMPLE+=("$1")
shift
Expand All @@ -1388,20 +1390,20 @@ fi

# Solr modules option
if [[ -n "${SOLR_MODULES:-}" ]] ; then
SOLR_OPTS+=("-Dsolr.modules=$SOLR_MODULES")
SCRIPT_SOLR_OPTS+=("-Dsolr.modules=$SOLR_MODULES")
fi

# Default placement plugin
if [[ -n "${SOLR_PLACEMENTPLUGIN_DEFAULT:-}" ]] ; then
SOLR_OPTS+=("-Dsolr.placementplugin.default=$SOLR_PLACEMENTPLUGIN_DEFAULT")
SCRIPT_SOLR_OPTS+=("-Dsolr.placementplugin.default=$SOLR_PLACEMENTPLUGIN_DEFAULT")
fi

# Remote streaming and stream body
if [ "${SOLR_ENABLE_REMOTE_STREAMING:-false}" == "true" ]; then
SOLR_OPTS+=("-Dsolr.enableRemoteStreaming=true")
SCRIPT_SOLR_OPTS+=("-Dsolr.enableRemoteStreaming=true")
fi
if [ "${SOLR_ENABLE_STREAM_BODY:-false}" == "true" ]; then
SOLR_OPTS+=("-Dsolr.enableStreamBody=true")
SCRIPT_SOLR_OPTS+=("-Dsolr.enableStreamBody=true")
fi

: ${SOLR_SERVER_DIR:=$DEFAULT_SERVER_DIR}
Expand Down Expand Up @@ -1494,15 +1496,15 @@ if [[ "$SCRIPT_CMD" == "stop" ]]; then
fi

if [ -n "${SOLR_PORT_ADVERTISE:-}" ]; then
SOLR_OPTS+=("-Dsolr.port.advertise=$SOLR_PORT_ADVERTISE")
SCRIPT_SOLR_OPTS+=("-Dsolr.port.advertise=$SOLR_PORT_ADVERTISE")
fi

if [ -n "${SOLR_JETTY_HOST:-}" ]; then
SOLR_OPTS+=("-Dsolr.jetty.host=$SOLR_JETTY_HOST")
SCRIPT_SOLR_OPTS+=("-Dsolr.jetty.host=$SOLR_JETTY_HOST")
fi

if [ -n "${SOLR_ZK_EMBEDDED_HOST:-}" ]; then
SOLR_OPTS+=("-Dsolr.zk.embedded.host=$SOLR_ZK_EMBEDDED_HOST")
SCRIPT_SOLR_OPTS+=("-Dsolr.zk.embedded.host=$SOLR_ZK_EMBEDDED_HOST")
fi

: "${STOP_PORT:=$((SOLR_PORT - 1000))}"
Expand Down Expand Up @@ -1736,8 +1738,8 @@ else
JAVA_MEM_OPTS=("-Xms$SOLR_HEAP" "-Xmx$SOLR_HEAP")
fi

# Pick default for Java thread stack size, and then add to SOLR_OPTS
SOLR_OPTS+=(${SOLR_JAVA_STACK_SIZE:-"-Xss256k"})
# Pick default for Java thread stack size, and then add to SCRIPT_SOLR_OPTS
SCRIPT_SOLR_OPTS+=(${SOLR_JAVA_STACK_SIZE:-"-Xss256k"})

: "${SOLR_TIMEZONE:=UTC}"

Expand Down Expand Up @@ -1778,79 +1780,83 @@ function start_solr() {
fi

if [ -n "${SOLR_WAIT_FOR_ZK:-}" ]; then
SOLR_OPTS+=("-DwaitForZk=$SOLR_WAIT_FOR_ZK")
SCRIPT_SOLR_OPTS+=("-DwaitForZk=$SOLR_WAIT_FOR_ZK")
fi

if [ -n "${SOLR_DATA_HOME:-}" ]; then
SOLR_OPTS+=("-Dsolr.data.home=$SOLR_DATA_HOME")
SCRIPT_SOLR_OPTS+=("-Dsolr.data.home=$SOLR_DATA_HOME")
fi

if [ -n "${SOLR_DELETE_UNKNOWN_CORES:-}" ]; then
SOLR_OPTS+=("-Dsolr.deleteUnknownCores=$SOLR_DELETE_UNKNOWN_CORES")
SCRIPT_SOLR_OPTS+=("-Dsolr.deleteUnknownCores=$SOLR_DELETE_UNKNOWN_CORES")
fi

# If SSL-related system props are set, add them to SOLR_OPTS
# If SSL-related system props are set, add them to SCRIPT_SOLR_OPTS
if [ "$SOLR_SSL_ENABLED" == "true" ]; then
# If using SSL and solr.jetty.https.port not set explicitly, use the jetty.port
SSL_PORT_PROP="-Dsolr.jetty.https.port=$SOLR_PORT"
SOLR_OPTS+=($SOLR_SSL_OPTS "$SSL_PORT_PROP")
SCRIPT_SOLR_OPTS+=($SOLR_SSL_OPTS "$SSL_PORT_PROP")
fi

# If authentication system props are set, add them to SOLR_OPTS
# If authentication system props are set, add them to SCRIPT_SOLR_OPTS
if [ -n "$AUTHC_OPTS" ]; then
SOLR_OPTS+=($AUTHC_OPTS)
SCRIPT_SOLR_OPTS+=($AUTHC_OPTS)
fi

# If there are internal options set by Solr (users should not use this variable), add them to SOLR_OPTS
# If there are internal options set by Solr (users should not use this variable), add them to SCRIPT_SOLR_OPTS
if [ -n "$SOLR_OPTS_INTERNAL" ]; then
SOLR_OPTS+=($SOLR_OPTS_INTERNAL)
SCRIPT_SOLR_OPTS+=($SOLR_OPTS_INTERNAL)
fi

# If a heap dump directory is specified, enable it in SOLR_OPTS
# If a heap dump directory is specified, enable it in SCRIPT_SOLR_OPTS
if [[ -z "${SOLR_HEAP_DUMP_DIR:-}" ]] && [[ "${SOLR_HEAP_DUMP:-}" == "true" ]]; then
SOLR_HEAP_DUMP_DIR="${SOLR_LOGS_DIR}/dumps"
fi
if [[ -n "${SOLR_HEAP_DUMP_DIR:-}" ]]; then
SOLR_OPTS+=("-XX:+HeapDumpOnOutOfMemoryError")
SOLR_OPTS+=("-XX:HeapDumpPath=$SOLR_HEAP_DUMP_DIR/solr-$(date +%s)-pid$$.hprof")
SCRIPT_SOLR_OPTS+=("-XX:+HeapDumpOnOutOfMemoryError")
SCRIPT_SOLR_OPTS+=("-XX:HeapDumpPath=$SOLR_HEAP_DUMP_DIR/solr-$(date +%s)-pid$$.hprof")
fi

if $verbose ; then
echo -e "\nStarting Solr using the following settings:"
echo -e " JAVA = $JAVA"
echo -e " SOLR_SERVER_DIR = $SOLR_SERVER_DIR"
echo -e " SOLR_HOME = $SOLR_HOME"
echo -e " SOLR_HOST = ${SOLR_HOST:-}"
echo -e " SOLR_PORT = $SOLR_PORT"
echo -e " STOP_PORT = $STOP_PORT"
echo -e " JAVA_MEM_OPTS = ${JAVA_MEM_OPTS[*]}"
echo -e " GC_TUNE = ${GC_TUNE_ARR[*]}"
echo -e " GC_LOG_OPTS = ${GC_LOG_OPTS[*]}"
echo -e " SOLR_TIMEZONE = $SOLR_TIMEZONE"
echo -e " JAVA = $JAVA"
echo -e " SOLR_SERVER_DIR = $SOLR_SERVER_DIR"
echo -e " SOLR_HOME = $SOLR_HOME"
echo -e " SOLR_HOST = ${SOLR_HOST:-}"
echo -e " SOLR_PORT = $SOLR_PORT"
echo -e " STOP_PORT = $STOP_PORT"
echo -e " JAVA_MEM_OPTS = ${JAVA_MEM_OPTS[*]}"
echo -e " GC_TUNE = ${GC_TUNE_ARR[*]}"
echo -e " GC_LOG_OPTS = ${GC_LOG_OPTS[*]}"
echo -e " SOLR_TIMEZONE = $SOLR_TIMEZONE"

if [ "$SOLR_MODE" == "solrcloud" ]; then
echo -e " CLOUD_MODE_OPTS = ${CLOUD_MODE_OPTS[*]}"
echo -e " CLOUD_MODE_OPTS = ${CLOUD_MODE_OPTS[*]}"
fi

if [ -n "${SOLR_OPTS:-}" ]; then
echo -e " SOLR_OPTS = ${SOLR_OPTS[*]}"
echo -e " SOLR_OPTS (USER) = ${SOLR_OPTS[*]}"
fi

if [ -n "${SCRIPT_SOLR_OPTS:-}" ]; then
echo -e " SOLR_OPTS (SCRIPT) = ${SCRIPT_SOLR_OPTS[*]}"
fi

if [ -n "${SOLR_ADDL_ARGS:-}" ]; then
echo -e " SOLR_ADDL_ARGS = $SOLR_ADDL_ARGS"
echo -e " SOLR_ADDL_ARGS = $SOLR_ADDL_ARGS"
fi

if [ "${ENABLE_REMOTE_JMX_OPTS:-false}" == "true" ]; then
echo -e " RMI_PORT = ${RMI_PORT:-}"
echo -e " REMOTE_JMX_OPTS = ${REMOTE_JMX_OPTS[*]}"
echo -e " RMI_PORT = ${RMI_PORT:-}"
echo -e " REMOTE_JMX_OPTS = ${REMOTE_JMX_OPTS[*]}"
fi

if [ -n "${SOLR_LOG_LEVEL:-}" ]; then
echo -e " SOLR_LOG_LEVEL = $SOLR_LOG_LEVEL"
echo -e " SOLR_LOG_LEVEL = $SOLR_LOG_LEVEL"
fi

if [ -n "${SOLR_DATA_HOME:-}" ]; then
echo -e " SOLR_DATA_HOME = $SOLR_DATA_HOME"
echo -e " SOLR_DATA_HOME = $SOLR_DATA_HOME"
fi
echo
fi
Expand All @@ -1865,14 +1871,14 @@ function start_solr() {

# Workaround for JIT crash, see https://issues.apache.org/jira/browse/SOLR-16463
if [[ "$JAVA_VER_NUM" -ge "17" ]] ; then
SOLR_OPTS+=("-XX:CompileCommand=exclude,com.github.benmanes.caffeine.cache.BoundedLocalCache::put")
SCRIPT_SOLR_OPTS+=("-XX:CompileCommand=exclude,com.github.benmanes.caffeine.cache.BoundedLocalCache::put")
echo "Java $JAVA_VER_NUM detected. Enabled workaround for SOLR-16463"
fi

# Vector optimizations are only supported for Java 20 and 21 for now.
# This will need to change as Lucene is upgraded and newer Java versions are released
if [[ "$JAVA_VER_NUM" -ge "20" ]] && [[ "$JAVA_VER_NUM" -le "21" ]] ; then
SOLR_OPTS+=("--add-modules" "jdk.incubator.vector")
SCRIPT_SOLR_OPTS+=("--add-modules" "jdk.incubator.vector")
echo "Java $JAVA_VER_NUM detected. Incubating Panama Vector APIs have been enabled"
fi

Expand All @@ -1886,7 +1892,7 @@ function start_solr() {
# OOME is thrown. Program operation after OOME is unpredictable.
"-XX:+CrashOnOutOfMemoryError" "-XX:ErrorFile=${SOLR_LOGS_DIR}/jvm_crash_%p.log" \
"-Djetty.home=$SOLR_SERVER_DIR" "-Dsolr.solr.home=$SOLR_HOME" "-Dsolr.install.dir=$SOLR_TIP" "-Dsolr.install.symDir=$SOLR_TIP_SYM" \
"-Dsolr.default.confdir=$DEFAULT_CONFDIR" "${LOG4J_CONFIG[@]}" "${SOLR_OPTS[@]}" "${SECURITY_MANAGER_OPTS[@]}" "${SOLR_ADMIN_UI}")
"-Dsolr.default.confdir=$DEFAULT_CONFDIR" "${LOG4J_CONFIG[@]}" "${SCRIPT_SOLR_OPTS[@]}" "${SECURITY_MANAGER_OPTS[@]}" "${SOLR_ADMIN_UI}" "${SOLR_OPTS[@]}")

mk_writable_dir "$SOLR_LOGS_DIR" "Logs"
if [[ -n "${SOLR_HEAP_DUMP_DIR:-}" ]]; then
Expand Down
Loading

0 comments on commit d16ae0e

Please sign in to comment.