Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop FileWatcher default instance on dedicated server exit #1757

Conversation

sciwhiz12
Copy link
Member

This PR fixes #1626 by stopping the default FileWatcher instance when the dedicated server instance exits (from DedicatedServer#onServerExit()).

This prevents the FileWatcher instance from blocking the JVM from exiting normally, as the instance keeps alive a non-daemon thread (and the JVM waits on all non-daemon threads to exit).

This is meant to be a temporary bugfix, until a bugfix is landed in NightConfig that marks the pool thread it creates as a daemon thread. (Follow the linked issue for more details.)

Tested by following the listed reproduction steps in the issue (which is important, since the FileWatcher has to be triggered once for the erring pool thread to be made), and observing that the JVM does exit soon after the server is stopped through /stop.


Out of the 'normal' runs, the dedicated server is affected. The client and the game test server exit the JVM using System.exit, as seen in Minecraft#destroy and GameTestServer#onServerExit respectively. The datagenerator, both client and server, does not load the configs, as seen in CommonModLoader#begin.

The JUnit server might be affected, but I am unsure if it is truly affected, since it may be that JUnit itself does a System.exit at the end of testing to handle the exit codes itself. I'm leaning towards the possibility that it is unaffected due to the special considerations of JUnit.

This prevents the FileWatcher instance from blocking the JVM from
exiting normally, as the instance keeps alive a non-daemon thread (and
the JVM waits on all non-daemon threads to exit).

Fixes neoforged#1626
@sciwhiz12 sciwhiz12 added bug A bug or error backport Backport to an older version from a newer version 1.21.4 Targeted at Minecraft 1.21.4 and removed backport Backport to an older version from a newer version labels Dec 11, 2024
@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Dec 11, 2024

  • Publish PR to GitHub Packages

Last commit published: c472ab2bc31359280b13fa2e30cfdecf93cdd685.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #1757' // https://github.com/neoforged/NeoForge/pull/1757
        url 'https://prmaven.neoforged.net/NeoForge/pr1757'
        content {
            includeModule('net.neoforged', 'testframework')
            includeModule('net.neoforged', 'neoforge')
        }
    }
}

MDK installation

In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr1757.
On Powershell you will need to remove the -L flag from the curl invocation.

mkdir NeoForge-pr1757
cd NeoForge-pr1757
curl -L https://prmaven.neoforged.net/NeoForge/pr1757/net/neoforged/neoforge/21.4.15-beta-pr-1757-1.21.4-GH-1626-filewatcher-dediserver-shutdown/mdk-pr1757.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip

To test a production environment, you can download the installer from here.

Copy link
Member

@embeddedt embeddedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fairly major bug, we should ideally backport the fix to 1.21.1 as well.

@TelepathicGrunt
Copy link
Contributor

Will merge if no objections by tomorrow (like 8 hours from now lol)

@TelepathicGrunt TelepathicGrunt merged commit f8e6502 into neoforged:1.21.x Dec 11, 2024
7 checks passed
@neoforged-releases
Copy link

🚀 This PR has been released as NeoForge version 21.4.17-beta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.4 Targeted at Minecraft 1.21.4 bug A bug or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NightConfig's FileWatcher not correctly shutdown causing servers to hang
3 participants