imbajin commented on code in PR #3258:
URL: https://github.com/apache/hugegraph/pull/3258#discussion_r4172351922
##########
hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh:
##########
@@ -121,13 +121,43 @@ if [ "$JAVA_OPTIONS" = "" ]; then
echo "Failed to start HugeGraphServer, requires at least ${MIN_MEM}MB
free memory" >> "${OUTPUT}"
exit 1
fi
- JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m -XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=${LOGS} ${USER_OPTION}"
+ JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m ${USER_OPTION}"
# Rolling out detailed GC logs
#JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseGCLogFileRotation
-XX:GCLogFileSize=10M -XX:NumberOfGCLogFiles=3 \
# -Xloggc:./logs/gc.log -XX:+PrintHeapAtGC
-XX:+PrintGCDetails -XX:+PrintGCDateStamps"
fi
+# Keep heap dumps and JVM crash logs in $LOGS whatever JAVA_OPTIONS holds.
They go
+# first so a value from JAVA_OPTIONS, -j or _JAVA_OPTIONS, all later on the
command
+# line, still wins. JAVA_TOOL_OPTIONS and JDK_JAVA_OPTIONS are read before the
command
+# line, so a flag set there is left out here instead of being overridden.
+# A restarted container often reuses the JVM's PID, and HotSpot will not
overwrite an
+# existing crash log or heap dump, so the file names also carry the launch
time. The
+# script execs java below, so $$ is the JVM's PID.
+LAUNCH_STAMP=$(date +%Y%m%d-%H%M%S)
+CRASH_OPTIONS=""
+SET_HEAP_DUMP="true"
+SET_HEAP_DUMP_PATH="true"
+SET_ERROR_FILE="true"
+for OPTION in ${JAVA_TOOL_OPTIONS:-} ${JDK_JAVA_OPTIONS:-}; do
+ case "${OPTION}" in
+ -XX:[+-]HeapDumpOnOutOfMemoryError) SET_HEAP_DUMP="false" ;;
+ -XX:HeapDumpPath=*) SET_HEAP_DUMP_PATH="false" ;;
+ -XX:ErrorFile=*) SET_ERROR_FILE="false" ;;
Review Comment:
⚠️ When OpenTelemetry is enabled, a crash flag found in JAVA_TOOL_OPTIONS is
omitted from CRASH_OPTIONS here. The telemetry block later replaces
JAVA_TOOL_OPTIONS with only the -javaagent option, so the original flag
disappears and HotSpot falls back to its working-directory crash path instead
of the configured LOGS path. Please preserve the operator's JAVA_TOOL_OPTIONS
when adding the agent, or restore the launcher default after replacing it.
Evidence: the new scan at lines 143-159 and the telemetry export at line 269.
--
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]