EssentialsX

EssentialsX

2M Downloads

Last logout time for /seen not updated on server restart

mibby opened this issue · 10 comments

commented

EssentialsX dev 780

It seems essential user files for users loaded / logged in are not saved when the server restarts. It doesn't flush to disk on shutdown procedure to save their last login times.

  • Have a user who has last logged in 4 days ago.
  • User logs in. Their /seen time is now online.
  • The server restarts automatically during a scheduled reboot while they are online. It goes through the entire shutdown /stop procedure, then spins back online with its start-up arguments.
  • Checking the player who was online, their last seen activity was 4 days ago still.

Apparently this bug has existed for a while and is why some of my users log off before automatic restarts.

commented

The files save completely fine. The problem with the /seen command is that it uses the last offline time for offline players, which is never updated when the server restarts (plugins cannot tell if players leave when they are being disabled)

This might require some NMS as there is yet to be an API to figure out when the server is stopping versus reloading.

commented

Aren't players disconnected before the plugin gets disabled?

To my knowledge Bukkit doesn't expose any events that reflect the server's actual lifecycle to plugins whatsoever, but rather only provides plugin lifecycle hooks (load, enable, disable). Even with NMS I don't see a way to check if an onDisable call is as a result of a shutdown - perhaps a "pre-shutdown" event could be added to Spigot/Paper if this is actually necessary.

commented

Aren't players disconnected before the plugin gets disabled?

No, looking at the source can verify this. You can also verify this by writing a experimental plugin to print whenever a player disconnects. You will notice that nothing is printed if you join the server and the server stops.

Even with NMS I don't see a way to check if an onDisable call is as a result of a shutdown - perhaps a "pre-shutdown" event could be added to Spigot/Paper if this is actually necessary.

A flag is set when the server shuts down in order to halt the main thread, it’s MinecraftServer#isRunning or something like that. When the server reloads, this flag is not set. It is indeed possible for plugins to definitively figure out when the server is stopping from the onDisable.

I agree, though, that it would be ideal if the API could expose a way to check this without resorting to NMS. I found this issue from almost 3 years ago, but based on md5’s response, there’s little hope of Spigot implementing such a feature.

commented

Due to this sort of issue, I usually make a habit of running a /kickall as part of the stopping routine. I will admit that it's more of a workaround than an actual solution though. This sounds like something that should be fixed on Spigot/Paper's end though (at least as far as providing an event), based on what's been discussed so far.

commented

Any possible verdict on how or whether this problem should be solved?

commented

No clue. I think it would be nice to fix, but this sounds like a problem with the server software rather than Essentials. If there is a way to mitigate this in a sane and reasonable way, that would probably be best, as this does impact data integrity.

Of course, a workaround is for server owners to simply disconnect players before stopping the server, either manually or via script. However all that accomplishes is pushing the responsibility off of the plugin and towards server owners. Thinking twice on that, it doesn't sound ideal.

Perhaps it would also be "good enough" to update the last seen time when the player connects. Or on some other interval (while avoiding writing to disk too frequently).

commented

Will fix pending a PR in Paper: PaperMC/Paper#3129

commented

@JRoy The issue is without this being in specifically the Bukkit API, this is essentially useless to Essentials unless someone wants to go out of their way to implement this in PaperLib or in a separate module

commented

@md678685 @JRoy This does not seem fixed with commit fc2b7b6 on Essentials dev 912. I had a user join for the first time today and then log off shortly afterwards. The server has restarted an hour or so later automatically. They have not been on since and their /seen time says Warning: The user 'burgertown' has never joined this server..

Logs of the user.
https://paste.ubuntu.com/p/MZCWNxmzJz/

Their essentials user file.
https://paste.ubuntu.com/p/ssHxWX5nx5/

commented

@mibby Apologies for the late response, but this should be fixed in subsequent builds.