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

Fabric server does not shutdown on stop command #3519

Closed
DearFox opened this issue Jan 27, 2023 · 19 comments · Fixed by #4029
Closed

Fabric server does not shutdown on stop command #3519

DearFox opened this issue Jan 27, 2023 · 19 comments · Fixed by #4029
Labels
Confirmed Bug The bug reported is confirmed and able to be replicated.

Comments

@DearFox
Copy link

DearFox commented Jan 27, 2023

Describe the bug

When you stop the Fabric server, the server does not shut down completely, resulting in the need to use C^ to shut down the server. This breaks automatic server restarts.

To Reproduce

  1. Start the fabric-server-mc.1.19.3-loader.0.14.13-launcher.0.11.1 with fabric-api-0.73.0+1.19.3 and the newly built Geyser-Fabric from the master branch
  2. Log in to the server via Bedrock (I'm using the Android version)
  3. Everything works? Log out of the server.
  4. Write to the server console /stop
  5. The server stops but the console is still open and the process is not completely stopped.

Expected behaviour

The server is completely stopped and the console is closed (as it usually happens when the server is stopped)

Screenshots / Videos

No response

Server Version and Plugins

No response

Geyser Dump

https://dump.geysermc.org/P0ex2z5ML3tyXoWyJRSX5MQ2meMR8qsq

Geyser Version

2.1.0-SNAPSHOT (git-master-af5d03f)

Minecraft: Bedrock Edition Device/Version

No response

Additional Context

I downloaded the master branch and built it.
Then I added the missing mappings and languages folders to Geyser-Fabric.jar
Everything works great except /stop command (only if someone connected to the server via bedrock)

@Ej747
Copy link

Ej747 commented Jan 28, 2023

I get this too. Does yours look similar to this?
image

@DearFox
Copy link
Author

DearFox commented Jan 29, 2023

I get this too. Does yours look similar to this? image
Yes, something like this

[06:00:00] [Server thread/INFO]: Stopping the server
[06:00:00] [Server thread/INFO]: Выключение Geyser.
[06:00:00] [Server thread/INFO]: Geyser успешно выключен.
[06:00:00] [Server thread/INFO]: Stopping server
[06:00:00] [Server thread/INFO]: Saving players
[06:00:00] [Server thread/INFO]: Saving worlds
[06:00:01] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[06:00:01] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
[06:00:01] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
[06:00:01] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[06:00:01] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[06:00:01] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[06:00:01] [Server thread/INFO]: ThreadedAnvilChunkStorage: All dimensions are saved
[06:00:01] [Server thread/INFO]: Shutting down EasyAuth.
[06:00:01] [Server thread/INFO]: Database connection closed successfully

@DearFox
Copy link
Author

DearFox commented Jan 29, 2023

I also found out about this in the Fabric discord
Perhaps this will be of some help in solving this problem.
image

@onebeastchris
Copy link
Member

I cannot reproduce this shutdown issue with just Geyser-Fabric. However, this issue does occur with floodgate-fabric installed, caused most likely by bstats there. Not Geyser-Fabric though; so no idea how Geyser-fabric alone does this in your case

@DearFox
Copy link
Author

DearFox commented Feb 6, 2023

I cannot reproduce this shutdown issue with just Geyser-Fabric. However, this issue does occur with floodgate-fabric installed, caused most likely by bstats there. Not Geyser-Fabric though; so no idea how Geyser-fabric alone does this in your case

In your tests, at least 1 player entered the server with minecraft bedrock (android)?
and I don't use floodgate-fabric on my server.
and i just checked, same thing happens on quilt server 1.19.3

@onebeastchris
Copy link
Member

Ah, I didn't actually test with players online, just the shutdown behavior itself. I'll see if I can reproduce it with a player join; I'll post here later

@onebeastchris
Copy link
Member

Thanks for that info, I'm now able to replicate this:
https://paste.gg/p/anonymous/84e53bf6b98e429a93e982727079163e here a list of all the running threads after running /stop, looks like a Geyser player thread isn't closed properly.

@DearFox
Copy link
Author

DearFox commented Feb 10, 2023

2.1.0-SNAPSHOT (git-master-9b3b2fb) the problem is still there

@petersv5
Copy link
Contributor

Still there in build 238.

@Konicai
Copy link
Member

Konicai commented Jul 18, 2023

Likely caused by this: GeyserMC/MCProtocolLib#699

@petersv5
Copy link
Contributor

jstack of Minecraft with Fabric, Geyser and Floodgate hung after a stop:
jstack.txt

@petersv5
Copy link
Contributor

I tried adding a shutdown of the EventLoopPool for the geyser player thread event pool. That got rid of some of the lingering threads. However, there are still some lingering threads:
jstack2.txt

@petersv5
Copy link
Contributor

petersv5 commented Aug 3, 2023

Likely caused by this: GeyserMC/MCProtocolLib#699

I suspect it has to do with TcpClientSocket in PacketLib creating an EventLoopGroup (static class variable) that is never shut down. See GeyserMC/PacketLib#49.

@petersv5
Copy link
Contributor

petersv5 commented Aug 3, 2023

I was looking at the wrong PacketLib implementation. I see that in the version used from MCProtocolLib there is a Shutdown hook that is supposed to close the EventLoopGroup.

I will check if this is called properly.

@petersv5
Copy link
Contributor

petersv5 commented Aug 3, 2023

Shutting down the EventLoopGroup in TcpClientSession removed one of the blocking threads.
The only blocking thread seems to have been created during a call to requestSkinAndCape() which in turn calls CompletableFuture.supplyAsync(). This thread seems not to be stopped

@petersv5
Copy link
Contributor

petersv5 commented Aug 3, 2023

By shutting down the EXECUTOR_SERVICE in SkinProvider as well I got a clean shutdown even after a Bedrock player had been connected.

Should I file this collection of hack-ish changes as a PR? It is probably needs a lot of rework by someone that understands how the components are supposed to interact inside Geyser.

@Camotoy
Copy link
Member

Camotoy commented Aug 3, 2023

Absolutely feel free to make a PR and we'll work from there if changes are needed.

@petersv5
Copy link
Contributor

petersv5 commented Aug 3, 2023

I created #4029 (#4029) for Geyser and GeyserMC/MCProtocolLib#744 for MCProtocolLib.

I would again like to stress that these are PoC hacks to verify that it was indeed the thread pools that were keeping the server from stopping after a Bedrock player had been on the server.

@rtm516 rtm516 linked a pull request Aug 3, 2023 that will close this issue
@petersv5
Copy link
Contributor

petersv5 commented Aug 5, 2023

I updated the PRs above with updates as mentioned. Most important is that /geyser reload works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Confirmed Bug The bug reported is confirmed and able to be replicated.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants