Player migration leaving behind duplicate entries in database
DasBabyPixel opened this issue · 2 comments
Stacktrace
SEVERE: Exception whilst handling packet BasePacket(channel=1, dataBuf=eu.cloudnetservice.driver.network.netty.buffer.NettyImmutableDataBuf@451d1052, prioritized=false, creationStamp=2023-08-17T00:22:26.005629502Z, uniqueId=null)
java.lang.IllegalStateException: Exception posting packet from channel 1 to handler eu.cloudnetservice.node.network.listener.PacketServerChannelMessageListener
at eu.cloudnetservice.driver.network.protocol.defaults.DefaultPacketListenerRegistry.handlePacket(DefaultPacketListenerRegistry.java:178)
at eu.cloudnetservice.driver.network.netty.NettyNetworkHandler.doHandlePacket(NettyNetworkHandler.java:123)
at eu.cloudnetservice.driver.network.netty.NettyNetworkHandler.lambda$messageReceived$0(NettyNetworkHandler.java:95)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: eu.cloudnetservice.driver.event.EventListenerException: Error while invoking event listener handle in class eu.cloudnetservice.modules.bridge.node.network.NodePlayerChannelMessageListener
at eu.cloudnetservice.driver.event.DefaultRegisteredEventListener.fireEvent(DefaultRegisteredEventListener.java:102)
at eu.cloudnetservice.driver.event.DefaultEventManager.callEvent(DefaultEventManager.java:87)
at eu.cloudnetservice.driver.event.EventManager.callEvent(EventManager.java:75)
at eu.cloudnetservice.node.network.listener.PacketServerChannelMessageListener.handle(PacketServerChannelMessageListener.java:70)
at eu.cloudnetservice.driver.network.protocol.defaults.DefaultPacketListenerRegistry.handlePacket(DefaultPacketListenerRegistry.java:176)
... 5 more
Caused by: java.lang.NullPointerException: proxyInfo is marked non-null but is null
at eu.cloudnetservice.modules.bridge.player.CloudOfflinePlayer.<init>(CloudOfflinePlayer.java:62)
at eu.cloudnetservice.modules.bridge.player.CloudPlayer.<init>(CloudPlayer.java:76)
at eu.cloudnetservice.modules.bridge.node.player.NodePlayerManager.selectPlayerForLogin(NodePlayerManager.java:371)
at eu.cloudnetservice.modules.bridge.node.player.NodePlayerManager.loginPlayer0(NodePlayerManager.java:332)
at eu.cloudnetservice.modules.bridge.node.player.NodePlayerManager.loginPlayer(NodePlayerManager.java:321)
at eu.cloudnetservice.modules.bridge.node.network.NodePlayerChannelMessageListener.handle(NodePlayerChannelMessageListener.java:135)
at dev.derklaro.reflexion.internal.handles.MethodHandleAccessorFactory$MethodHandleMethodAccessor.lambda$invoke$1(MethodHandleAccessorFactory.java:396)
at dev.derklaro.reflexion.Result.tryExecute(Result.java:80)
at dev.derklaro.reflexion.internal.handles.MethodHandleAccessorFactory$MethodHandleMethodAccessor.invoke(MethodHandleAccessorFactory.java:394)
at dev.derklaro.reflexion.internal.handles.MethodHandleAccessorFactory$MethodHandleMethodAccessor.invokeWithArgs(MethodHandleAccessorFactory.java:380)
at eu.cloudnetservice.driver.event.DefaultRegisteredEventListener.fireEvent(DefaultRegisteredEventListener.java:96)
... 9 more
Actions to reproduce
Use a (filled) database from cloudnet 3. This should start migration to the new data version:
But then when you try to join you get the error above.
After a little bit of experimenting I found out it is because there are duplicate entries in the database:
Manually deleting the old entry fixes the problem
CloudNet version
[17.08 02:33:27.887] INFO:
[17.08 02:33:27.889] INFO: CloudNet Blizzard 4.0.0-RC9 f6ca4c38
[17.08 02:33:27.890] INFO: Discord: <https://discord.cloudnetservice.eu/>
[17.08 02:33:27.890] INFO:
[17.08 02:33:27.891] INFO: ClusterId: 9da8725e-****-481a-****-4b9b7fbc608f
[17.08 02:33:27.891] INFO: NodeId: Node-1
[17.08 02:33:27.891] INFO: Head-NodeId: Node-1
[17.08 02:33:27.892] INFO: CPU usage: (P/S) 3.14/44.91/100%
[17.08 02:33:27.892] INFO: Node services memory allocation (U/R/M): 2048/2048/4096 MB
[17.08 02:33:27.892] INFO: Threads: 42
[17.08 02:33:27.893] INFO: Heap usage: 36/256MB
[17.08 02:33:27.893] INFO: JVM: Eclipse Adoptium 17 (OpenJDK 64-Bit Server VM 17.0.6+10)
[17.08 02:33:27.893] INFO: Update Repo: CloudNetService/launchermeta, Update Branch: beta
[17.08 02:33:27.894] INFO:
Other
I have to add that I did not first use RC1, RC2, RC3, etc until RC9 but immediately used RC9. But that said there still is no reason for this not to work correctly
Issue uniqueness
- Yes, this issue is unique. There are no similar issues.
I'm not sure what type of database you're using (looks like MySQL), but the player uuid (or, to be more specific, the entry key) is marked as primary and the sql statement for insert states that an update should happen in case of a duplicate entry:
INSERT INTO
(key, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?;
(simplified).
This means that the issue should not happen, or at least, the operation should throw an error in case of a violated primary key constraint. It might be due to a missing primary key in the old v3 database, can you check that?
Yeah I am using MySQL(MariaDB), and the old v3 Database and after some inspecting it seems that for some reason all my keys have the type TEXT and all my values LONGTEXT.
At this point I took a look in the code to find a reason for this and all I could find was this commit where really old databases might not have a primary key, but most of my databases are newer than that. I wasn't able to find a commit explaining the TEXT type as key, so right now I'm just going with "It's my fault", because I did some database exporting/importing some time back, which might explain this.
I'm going to close this unless someone else has something to add.