fix(gc-log): write the GC log under ./logs and guarantee the directory - #6918
Closed
barbatos2011 wants to merge 1 commit into
Closed
fix(gc-log): write the GC log under ./logs and guarantee the directory#6918barbatos2011 wants to merge 1 commit into
barbatos2011 wants to merge 1 commit into
Conversation
bin/FullNode configures GC logging through gradle/java-tron.vmoptions, which pointed at ./gc.log, while the application writes tron.log under ./logs. The two logs ended up in different places, and in container deployments only ./logs is normally mounted, so the GC log stayed inside the container and was lost with it. Point both vmoptions files at ./logs/gc.log, and create the directory in the launcher before the JVM starts. The mkdir is required rather than cosmetic. java-tron creates ./logs at application startup, which is too late, because JVM logging is initialised first. On JDK 9+ a missing directory is fatal instead of a warning, so on the arm64/JDK 17 build the node would refuse to start: Invalid -Xlog option '-Xlog:gc,gc+heap:file=./logs/gc.log:...' Error: Could not create the Java Virtual Machine. [error][logging] Error opening log file './logs/gc.log': No such file or directory Verified on linux/arm64 (JDK 17.0.19, ZGC): the node starts and gc.log appears in ./logs next to tron.log. Without the mkdir the same configuration fails as shown above. start.sh is left unchanged. It invokes the JVM directly with its own -Xloggc:./gc.log, does not read vmoptions, and its GC log rotation expects that location.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bin/FullNodeconfigures GC logging throughgradle/java-tron.vmoptions, which points at./gc.log. The application, meanwhile, writestron.logunder./logs. The two logs land in different places.That split matters most in container deployments. tron-docker and the
docker/compose files mount./logsfrom the host, sotron.logis available outside the container whilegc.logsits at/java-tron/gc.logand disappears when the container is removed.Change
Point both vmoptions files at
./logs/gc.log, and create the directory in the launcher before the JVM starts.Why the mkdir is required, not cosmetic
java-tron creates
./logsat application startup, which is too late: JVM logging is initialised first. On JDK 9+ a missing log directory is fatal rather than a warning, so on the arm64/JDK 17 build the node refuses to start.Verified by building the published arm64 image with only the vmoptions change applied and no mkdir:
On JDK 8 the same situation is only a warning, so without the mkdir this would have been an arm64-only startup failure — exactly the kind of asymmetry that is easy to miss in review.
Verification
Both changes applied to
tronprotocol/java-tron:latest(linux/arm64,openjdk 17.0.19, ZGC), run through the real entrypoint:Scope notes
start.shis unchanged. It invokes the JVM directly with its own-Xloggc:./gc.log, never readsvmoptions, and its GC log rotation (backupGcLog) expects that location. Aligning it would mean changing that rotation logic too, which is left out deliberately. Happy to fold it in if maintainers prefer the two launch paths to match.gradle/windowsStartScript.txtis unchanged; it does not readvmoptions.bin/FullNode,gc.logmoves from the working directory to./logs/gc.log. Anything collecting it by path needs updating.Context
Related: tronprotocol/tron-docker#127, which removes JDK 8 GC options from the compose files because they break the arm64/JDK 17 image. This PR is what lets the GC log stay visible on the host after that change.