Skip to content

Commit

Permalink
Fix environment variable assignment in startup scripts (#13025)
Browse files Browse the repository at this point in the history
- don't combine variables in BOOKIE_EXTRA_OPTS
- don't add PULSAR_GC_LOG to PULSAR_EXTRA_OPTS
- make BOOKIE_GC_LOG default to PULSAR_GC_LOG for consistency
- apply PULSAR_EXTRA_OPTS and BOOKIE_EXTRA_OPTS after other settings so that it is possible to override
  settings defined by PULSAR_MEM / PULSAR_GC
  • Loading branch information
lhotari authored Dec 1, 2021
1 parent 42aa977 commit f00ee7b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/bookkeeper
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ OPTS="$OPTS -Dio.netty.tryReflectionSetAccessible=true"

OPTS="-cp $BOOKIE_CLASSPATH $OPTS"

OPTS="$OPTS $BOOKIE_EXTRA_OPTS"
OPTS="$OPTS $BOOKIE_MEM $BOOKIE_GC $BOOKIE_GC_LOG $BOOKIE_EXTRA_OPTS"

# Disable ipv6 as it can cause issues
OPTS="$OPTS -Djava.net.preferIPv4Stack=true"
Expand Down
4 changes: 2 additions & 2 deletions bin/pulsar
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ OPTS="-cp $PULSAR_CLASSPATH $OPTS"

if [ $COMMAND == "bookie" ]; then
# Pass BOOKIE_EXTRA_OPTS option defined in bkenv.sh
OPTS="$OPTS $BOOKIE_EXTRA_OPTS"
OPTS="$OPTS $BOOKIE_MEM $BOOKIE_GC $BOOKIE_GC_LOG $BOOKIE_EXTRA_OPTS"
else
OPTS="$OPTS $PULSAR_EXTRA_OPTS $PULSAR_MEM $PULSAR_GC"
OPTS="$OPTS $PULSAR_MEM $PULSAR_GC $PULSAR_GC_LOG $PULSAR_EXTRA_OPTS"
fi

# log directory & file
Expand Down
6 changes: 3 additions & 3 deletions conf/bkenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ BOOKIE_GC=${BOOKIE_GC:-${PULSAR_GC:-"-XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+P
IS_JAVA_8=`java -version 2>&1 |grep version|grep '"1\.8'`
# java version has space, use [[ -n $PARAM ]] to judge if variable exists
if [[ -n $IS_JAVA_8 ]]; then
BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-"-Xloggc:logs/pulsar_bookie_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M"}
BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-${PULSAR_GC_LOG:-"-Xloggc:logs/pulsar_bookie_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M"}}
else
# After jdk 9, gc log param should config like this. Ignoring version less than jdk 8
BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-"-Xlog:gc*:logs/pulsar_bookie_gc_%p.log:time,uptime,level,tags:filecount=10,filesize=20M"}
BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-${PULSAR_GC_LOG:-"-Xlog:gc*:logs/pulsar_bookie_gc_%p.log:time,uptime,level,tags:filecount=10,filesize=20M"}}
fi

# Extra options to be passed to the jvm
BOOKIE_EXTRA_OPTS="${BOOKIE_EXTRA_OPTS:-"-Dio.netty.leakDetectionLevel=disabled ${PULSAR_EXTRA_OPTS:-"-Dio.netty.recycler.maxCapacity.default=1000 -Dio.netty.recycler.linkCapacity=1024"}"} ${BOOKIE_MEM} ${BOOKIE_GC} ${BOOKIE_GC_LOG}"
BOOKIE_EXTRA_OPTS="${BOOKIE_EXTRA_OPTS:-"-Dio.netty.leakDetectionLevel=disabled ${PULSAR_EXTRA_OPTS:-"-Dio.netty.recycler.maxCapacity.default=1000 -Dio.netty.recycler.linkCapacity=1024"}"}"

# Add extra paths to the bookkeeper classpath
# BOOKIE_EXTRA_CLASSPATH=
Expand Down
2 changes: 1 addition & 1 deletion conf/pulsar_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ else
fi

# Extra options to be passed to the jvm
PULSAR_EXTRA_OPTS="${PULSAR_EXTRA_OPTS:-" -Dpulsar.allocator.exit_on_oom=true -Dio.netty.recycler.maxCapacity.default=1000 -Dio.netty.recycler.linkCapacity=1024"} ${PULSAR_GC_LOG}"
PULSAR_EXTRA_OPTS="${PULSAR_EXTRA_OPTS:-" -Dpulsar.allocator.exit_on_oom=true -Dio.netty.recycler.maxCapacity.default=1000 -Dio.netty.recycler.linkCapacity=1024"}"

# Add extra paths to the bookkeeper classpath
# PULSAR_EXTRA_CLASSPATH=
Expand Down

0 comments on commit f00ee7b

Please sign in to comment.