bitflicker64 commented on code in PR #3253:
URL: https://github.com/apache/hugegraph/pull/3253#discussion_r4530974458
##########
hugegraph-store/hg-store-dist/src/assembly/static/bin/start-hugegraph-store.sh:
##########
@@ -244,7 +351,7 @@ fi
# JAVA_OPTIONS="${JAVA_OPTIONS}
-javaagent:${LIB}/jmx_prometheus_javaagent-0.16.1.jar=${JMX_EXPORT_PORT}:${CONF}/jmx_exporter.yml"
#fi
-if [ "$(ps -ef | grep -v grep | grep java | grep -cE "${CONF}")" -ne 0 ]; then
+if [ "$(ps -ef | grep -v grep | grep java | grep -cF -- "${CONF}")" -ne 0 ];
then
Review Comment:
Important: `grep -F -- "${CONF}"` matches any process whose arguments
contain `$CONF` as a substring, so starting a Store with `-c /etc/hg/store`
while another runs with `-c /etc/hg/store-b` prints `already running` and exits
0 without launching. Match the full
`-Dspring.config.location=${CONF}/application.yml` argument here and at
`start-hugegraph-pd.sh` line 259.
##########
hugegraph-store/hg-store-dist/src/assembly/static/bin/start-hugegraph-store.sh:
##########
@@ -152,55 +192,111 @@ else
fi
# check jdk version
-JAVA_VERSION=$($JAVA -version 2>&1 |
+JAVA_VERSION=$("$JAVA" -version 2>&1 |
awk -F'"' '/^(java|openjdk) version "/ {print $2; exit}' |
sed 's/^1\.//' | cut -d'.' -f1)
JAVA_VERSION="${JAVA_VERSION%%[!0-9]*}"
if [[ -z $JAVA_VERSION || $JAVA_VERSION -lt $EXPECT_JDK_VERSION ]]; then
- echo "Please make sure that the JDK is installed and the version >=
$EXPECT_JDK_VERSION" >> ${OUTPUT}
+ echo "Please make sure that the JDK is installed and the version >=
$EXPECT_JDK_VERSION" >> "${OUTPUT}"
exit 1
fi
-# Set Java options
-if [ "$JAVA_OPTIONS" = "" ]; then
+# Set Java options.
+# Script-generated options are kept in arrays so that paths containing spaces
+# (overridden CONF/LOGS/PLUGINS) stay a single argument when passed to java.
+# User-supplied strings ($JAVA_OPTIONS / $USER_OPTION) keep the historical
+# word-splitting contract. Built in JAVA_OPTIONS_ARR (not JAVA_OPTIONS) so the
+# exported scalar JAVA_OPTIONS stays intact for any child inheriting this
+# environment (e.g. a later no-arg restart) -- Bash arrays cannot be exported.
+JAVA_OPTIONS_ENV="${JAVA_OPTIONS}"
+JAVA_OPTIONS_ARR=()
+if [ "$JAVA_OPTIONS_ENV" = "" ]; then
XMX=$(calc_xmx $MIN_MEM $MAX_MEM)
if [ $? -ne 0 ]; then
echo "Failed to start HugeGraphStoreServer, requires at least
${MIN_MEM}m free memory" \
- >> ${OUTPUT}
+ >> "${OUTPUT}"
exit 1
fi
- JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m -XX:MetaspaceSize=256M
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOGS} ${USER_OPTION} "
- # JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOGS} ${USER_OPTION}"
+ # Cap direct memory at the heap size picked here, the JVM's own unset
default, so the
+ # RocksDB auto-sizing (RocksdbMemoryBudget) counts a limit the JVM
actually enforces.
+ # Leave it out when -j sets the heap or the cap itself, or
JAVA_TOOL_OPTIONS or
+ # JDK_JAVA_OPTIONS sets the cap: a fixed cap from the computed heap would
no longer match
+ # a -j -Xmx, and the JVM then defaults it to that heap.
+ DIRECT_MEMORY_OPTION="-XX:MaxDirectMemorySize=${XMX}m"
+ # Split -j the way it reaches the JVM below (unquoted: spaces, tabs and
newlines)
+ for opt in ${USER_OPTION}; do
+ case "$opt" in
+ -Xmx* | -XX:MaxHeapSize=* | -XX:MaxDirectMemorySize=*)
DIRECT_MEMORY_OPTION="" ;;
+ esac
+ done
+ # The JVM reads JAVA_TOOL_OPTIONS and JDK_JAVA_OPTIONS before the command
line, so a cap
+ # there would lose to this one; keep it instead. The JVM drops quotes
anywhere in a token
+ # there, so drop them too. A false match, such as the text inside a quoted
-D value, only
+ # leaves the cap to the JVM, whose default is this same heap.
+ ENV_JVM_OPTIONS=" ${JAVA_TOOL_OPTIONS:-} ${JDK_JAVA_OPTIONS:-} "
+ ENV_JVM_OPTIONS="${ENV_JVM_OPTIONS//[\"\']/}"
+ case "${ENV_JVM_OPTIONS//[$'\t\r\n']/ }" in
+ *" -XX:MaxDirectMemorySize="*) DIRECT_MEMORY_OPTION="" ;;
+ esac
+ # Built purely in JAVA_OPTIONS_ARR (array) -- DIRECT_MEMORY_OPTION is only
+ # added when non-empty so no stray empty argv element is passed to java.
+ JAVA_OPTIONS_ARR=("-Xms${MIN_MEM}m" "-Xmx${XMX}m")
Review Comment:
Important: head `269fb75` records the latest upstream merge with only one
parent, so GitHub still diffs against `86c05ef` (591 files), reports the PR as
conflicting in this file and `docs/server-runtime.md`, and runs no CI at this
head. Redo the merge as a two-parent `git merge` of `upstream/master` (or
rebase onto it) so only the 35 launcher files remain in the diff.
##########
docs/server-runtime.md:
##########
@@ -30,6 +30,72 @@ component files. CI checks positive-test and startup logs
for Java module-access
errors and unsupported JVM options, including errors printed without failing
the
operation.
+### Gremlin and HStore transport reconnection
+
+The Gremlin security manager permits reads of the gRPC shaded Netty boolean
property
+`io.grpc.netty.shaded.io.grpc.netty.useCustomAllocator` and the DNS cache
setting
+`networkaddress.cache.ttl`. gRPC reads these settings when it builds a DNS
resolver or
+rebuilds a transport, including after a PD or Store restart during a Gremlin
request.
+Gremlin cannot set or clear these system properties. It also cannot change the
separate
+JDK security property `networkaddress.cache.ttl` through
`java.security.Security.setProperty`.
+Trusted code outside Gremlin can still configure these settings. Sensitive
system
+properties such as `user.home` remain unreadable from Gremlin.
+
+HStore constructs each target's lazy channel and stub pools on the calling
thread so
+initialization retains the caller's Gremlin security context. The client
publishes
+the pool after all channels are constructed. If construction throws a runtime
exception
+or an error, it closes the partial pool and reports the failure; a subsequent
request can retry.
+Cleanup failures are retained as suppressed exceptions, and an original error
is rethrown
+unchanged. RPC transport work remains asynchronous. This change does not grant
Gremlin permission to create
+threads or thread groups.
+
+The shared gRPC framework and provider discovery initialize during normal
PD/framework
+bootstrap before Server accepts Gremlin requests. This does not initialize the
pools
+for every future Store target. Unit checks that obtain a stub verify lazy pool
+construction; a successful RPC and its readback are separate runtime checks.
+
+### Launcher path overrides
+
+`bin/start-hugegraph.sh` accepts four path overrides. The override flags also
work in
+`bin/init-store.sh` (`-c`/`-o`), `bin/stop-hugegraph.sh` (`-i`) and the monitor
+cron job installed by `-m true`, so stop/restart/monitor stay consistent with
+the paths `bin/start-hugegraph.sh` used.
+
+| Flag | Meaning | Default (when omitted) |
+|---|---|---|
+| `-c <dir>` | Conf directory | `$TOP/conf` |
+| `-l <dir>` | Logs directory | `$TOP/logs` |
+| `-i <file>` | PID file | `$BIN/pid` |
+| `-o <dir>` | Plugins directory | `$TOP/plugins` |
+
+`$TOP` is the distribution's install root (the parent of `bin/`); `$BIN` is
+`$TOP/bin`.
+
+Relative values are resolved to absolute paths before use: `-l` and `-o` name
+directories the launcher writes into, so a relative or missing directory is
+created; `-c` and `-i` are only ever read, so a relative value is resolved
+without creating anything, and a missing `-c` directory is a startup error.
+A value for `-c` or `-i` must still be an existing path once resolved — the
+launcher does not create the external conf dir or a pid file's parent
+directory for you unless that parent already exists.
Review Comment:
Minor: this says the launcher never creates the `-i` parent directory, but
`canonicalize_file` in the start scripts runs `mkdir -p` on it; only the stop
scripts use `nocreate`. Describe `-i` as created by start and resolve-only in
stop, here and in the PD and Store `README.md` `-i` entries.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]