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

fix hang on shutdown for fabric due to hanging user threads #2460

Closed
wants to merge 1 commit into from

Conversation

petersv5
Copy link

The JVM initiates shutdown when all non-daemon java threads have terminated. When saving a schematic two threads are created that are never stopped, thus preventing the server for finishing the shutdown.

One is the "WorldEdit Task Executor - 0", shich is easily fixed.

The second is the TimerThread created by FutureProgressListener. In this patch the timer is made to use a deamon thread instead. If critical scheduled events on this timer persost after a server shutdown is otherwise complete maybe this needs to be changed to an executor service? Otherwise scheduled events may get lost by the server shutting down.

This fixes #2459

The JVM initiates shutdown when all non-daemon java threads have
terminated. When saving a schematic two threads are created that
are never stopped, thus preventing the server for finishing the
shutdown.

One is the "WorldEdit Task Executor - 0", shich is easily fixed.

The second is the TimerThread created by FutureProgressListener.
In this patch the timer is made to use a deamon thread instead. If
critical scheduled events on this timer persost after a server
shutdown is otherwise complete maybe this needs to be changed to
an executor service? Otherwise scheduled events may get lost by
the server shutting down.
@@ -286,6 +287,7 @@ private void onStopServer(MinecraftServer minecraftServer) {
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
WorldEdit.getInstance().getEventBus().post(new PlatformUnreadyEvent(platform));
WorldEdit.getInstance().getExecutorService().shutdown();
Copy link
Member

Choose a reason for hiding this comment

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

If this is something that must be shut down on Fabric, I feel that we should probably also shut this down on other platforms.

@@ -90,6 +90,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
Copy link
Member

Choose a reason for hiding this comment

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

This import also seems to be unnecessary, it should be removed

@me4502
Copy link
Member

me4502 commented Jul 7, 2024

i'll close this for now in favour of #2570 which has been merged. i'm uncertain whether making the Timer a daemon thread could cause some unknown issues, but shutting down the executor is fairly safe.

@me4502 me4502 closed this Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fabric with worldedit hangs when stopping during shutdown
2 participants