WiIIiam278 / HuskSync

A modern, cross-server player data synchronisation system
https://william278.net/project/husksync
Apache License 2.0
151 stars 122 forks source link

Player data desync on server change #292

Closed nhanledev closed 1 month ago

nhanledev commented 2 months ago

Player data sometimes doesn’t sync between the server until the player rejoins the network (quits the server and rejoins).

I’m not sure if this is a bug or if the server is too weak. However, this issue occurs even when there are only 2-3 players on the server, resulting in the following error. This error has been observed since the attribute sync update.

[10:05:08] [Server thread/INFO]: TheBestWarden issued server command: /back
[10:05:08] [Server thread/INFO]: TheBestWarden lost connection: Disconnected
[10:05:18] [Paper Watchdog Thread/ERROR]: --- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH  - git-Paper-455 (MC: 1.20.4) ---
[10:05:18] [Paper Watchdog Thread/ERROR]: The server has not responded for 10 seconds! Creating thread dump
[10:05:18] [Paper Watchdog Thread/ERROR]: ------------------------------
[10:05:18] [Paper Watchdog Thread/ERROR]: Server thread dump (Look for plugins here before reporting to Paper!):
[10:05:18] [Paper Watchdog Thread/ERROR]: ------------------------------
[10:05:18] [Paper Watchdog Thread/ERROR]: Current Thread: Server thread
[10:05:18] [Paper Watchdog Thread/ERROR]:   PID: 29 | Suspended: false | Native: true | State: RUNNABLE
[10:05:18] [Paper Watchdog Thread/ERROR]:   Stack:
[10:05:20] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 11311ms or 226 ticks behind
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/sun.nio.ch.FileDispatcherImpl.write0(Native Method)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/sun.nio.ch.FileDispatcherImpl.write(FileDispatcherImpl.java:62)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:132)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/sun.nio.ch.IOUtil.write(IOUtil.java:97)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/sun.nio.ch.IOUtil.write(IOUtil.java:67)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:288)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.nio.channels.Channels.writeFullyImpl(Channels.java:74)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.nio.channels.Channels.writeFully(Channels.java:96)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.nio.channels.Channels$1.write(Channels.java:171)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.io.BufferedOutputStream.write(BufferedOutputStream.java:127)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.util.zip.GZIPOutputStream.finish(GZIPOutputStream.java:168)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:244)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.io.FilterOutputStream.close(FilterOutputStream.java:188)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.io.FilterOutputStream.close(FilterOutputStream.java:188)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.nbt.NbtIo.writeCompressed(NbtIo.java:194)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.nbt.NbtIo.writeCompressed(NbtIo.java:146)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.world.level.storage.PlayerDataStorage.save(PlayerDataStorage.java:44)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.players.PlayerList.save(PlayerList.java:581)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.players.PlayerList.remove(PlayerList.java:637)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.players.PlayerList.remove(PlayerList.java:598)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.network.ServerGamePacketListenerImpl.removePlayerFromWorld(ServerGamePacketListenerImpl.java:2093)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2073)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2060)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.network.Connection.handleDisconnection(Connection.java:837)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.network.ServerConnectionListener.tick(ServerConnectionListener.java:254)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1746)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1525)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1226)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319)
[10:05:20] [Paper Watchdog Thread/ERROR]:       net.minecraft.server.MinecraftServer$$Lambda$6412/0x00007fd080c5fd58.run(Unknown Source)
[10:05:20] [Paper Watchdog Thread/ERROR]:       java.base@17.0.10/java.lang.Thread.run(Thread.java:840)
[10:05:20] [Paper Watchdog Thread/ERROR]: ------------------------------
[10:05:20] [Paper Watchdog Thread/ERROR]: --- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---
[10:05:20] [Paper Watchdog Thread/ERROR]: ------------------------------

Edit: My english is too funny, grammar correction.

nhanledev commented 2 months ago

This issue happens since the update of attribute synchronization. I have been running earlier version for a long time with no sync issue than the "health" one.

WiIIiam278 commented 2 months ago

It looks like it failed to finish processing the disconnect packet on your server due to thread timeout. Try disabling sync modes?

Honestly this is kind of unusual; I'm not doing anything massively expensive aside from reading player attribute data, is your server that low spec?

nhanledev commented 2 months ago

I find it unusual too since the TPS remain consistently at 20. This is the second time that my player report a desync problem since the update to 3.5. I plan to test a different infrastructure to determine if the issue persists. My current cpu is ryzen 5800x and it's a shared plan so I'm not sure if it's the spike, because if player don't disconnect from the network, the problem is still there each disconnection event.

WiIIiam278 commented 2 months ago

Your hardware seems reasonable enough

Looking at the trace in more detail - it seems like it's crashing on an I/O write of that player's data to their NBT data file (like, the actual .dat file in the playerdata directory on your server.

HuskSync doesn't prevent Minecraft from persisting user data to disk, as is by default, for redundancy purposes. Have you done something to remove permissions from writes to the playerdata directory in your world folder / are you doing stuff with that data to, say, delete or move it?

WiIIiam278 commented 1 month ago

Closing this as the issue reported seems specific to the user's case - if further help is needed, get in touch on Discord.