Stargate Rewritten

Stargate Rewritten

241 Downloads

[TMS TMP013] Unable to handle invalid central renames.

Pheotis opened this issue ยท 4 comments

commented

By changing the default network to a player's uuid (for example, cbd37628-2e35-4356-a2b8-7121895ef5b3 and using sg reload), the migration compat instance gets bricked. Restarting results in the same error.

[14:02:28] [Server thread/WARN]: org.sgrewritten.stargate.exception.database.StorageWriteException: org.sqlite.SQLiteException: [SQLITE_BUSY]  The database file is locked (database is locked)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.database.SQLDatabase.updateNetworkName(SQLDatabase.java:540)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.network.StargateRegistry.rename(StargateRegistry.java:256)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.network.StargateRegistry.rename(StargateRegistry.java:286)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.database.SQLDatabase.loadAllPortals(SQLDatabase.java:213)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.database.SQLDatabase.loadFromStorage(SQLDatabase.java:107)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.network.StargateRegistry.loadPortals(StargateRegistry.java:58)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.network.StargateRegistry.load(StargateRegistry.java:250)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.Stargate.reload(Stargate.java:509)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.command.CommandReload.onCommand(CommandReload.java:39)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.command.CommandStargate.onCommand(CommandStargate.java:35)
[14:02:28] [Server thread/WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[14:02:28] [Server thread/WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:148)
[14:02:28] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:702)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.PlayerConnection.handleCommand(PlayerConnection.java:1607)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1461)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(SourceFile:36)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(SourceFile:9)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(SourceFile:144)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(SourceFile:118)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.MinecraftServer.ba(MinecraftServer.java:876)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:869)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(SourceFile:127)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:853)
[14:02:28] [Server thread/WARN]:        at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:793)
[14:02:28] [Server thread/WARN]:        at java.base/java.lang.Thread.run(Thread.java:829)
[14:02:28] [Server thread/WARN]: Caused by: org.sqlite.SQLiteException: [SQLITE_BUSY]  The database file is locked (database is locked)
[14:02:28] [Server thread/WARN]:        at org.sqlite.core.DB.newSQLException(DB.java:941)
[14:02:28] [Server thread/WARN]:        at org.sqlite.core.DB.newSQLException(DB.java:953)
[14:02:28] [Server thread/WARN]:        at org.sqlite.core.DB.execute(DB.java:854)
[14:02:28] [Server thread/WARN]:        at org.sqlite.jdbc3.JDBC3PreparedStatement.execute(JDBC3PreparedStatement.java:56)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.util.database.DatabaseHelper.runStatement(DatabaseHelper.java:33)
[14:02:28] [Server thread/WARN]:        at org.sgrewritten.stargate.database.SQLDatabase.updateNetworkName(SQLDatabase.java:537)
[14:02:28] [Server thread/WARN]:        ... 27 more
[14:02:28] [Server thread/ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'sg' in plugin Stargate v1.0.0.13-ALPHA
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[bukkit.jar:git-Bukkit-8731c97]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:148) ~[bukkit.jar:git-Bukkit-8731c97]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:702) ~[bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.PlayerConnection.handleCommand(PlayerConnection.java:1607) ~[bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1461) ~[bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(SourceFile:36) ~[bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(SourceFile:9) ~[bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) [bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.MinecraftServer.ba(MinecraftServer.java:876) [bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:869) [bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(SourceFile:127) [bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:853) [bukkit.jar:git-Bukkit-8731c97]
        at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:793) [bukkit.jar:git-Bukkit-8731c97]
        at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.lang.IllegalArgumentException: UUID string too large
        at java.util.UUID.fromString(UUID.java:199) ~[?:?]
        at org.sgrewritten.stargate.network.LocalNetwork.loadAsPersonalNetwork(LocalNetwork.java:108) ~[?:?]
        at org.sgrewritten.stargate.network.LocalNetwork.load(LocalNetwork.java:76) ~[?:?]
        at org.sgrewritten.stargate.network.LocalNetwork.setID(LocalNetwork.java:274) ~[?:?]
        at org.sgrewritten.stargate.network.StargateRegistry.rename(StargateRegistry.java:260) ~[?:?]
        at org.sgrewritten.stargate.network.StargateRegistry.rename(StargateRegistry.java:286) ~[?:?]
        at org.sgrewritten.stargate.database.SQLDatabase.loadAllPortals(SQLDatabase.java:213) ~[?:?]
        at org.sgrewritten.stargate.database.SQLDatabase.loadFromStorage(SQLDatabase.java:107) ~[?:?]
        at org.sgrewritten.stargate.network.StargateRegistry.loadPortals(StargateRegistry.java:58) ~[?:?]
        at org.sgrewritten.stargate.network.StargateRegistry.load(StargateRegistry.java:250) ~[?:?]
        at org.sgrewritten.stargate.Stargate.reload(Stargate.java:509) ~[?:?]
        at org.sgrewritten.stargate.command.CommandReload.onCommand(CommandReload.java:39) ~[?:?]
        at org.sgrewritten.stargate.command.CommandStargate.onCommand(CommandStargate.java:35) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[bukkit.jar:git-Bukkit-8731c97]
        ... 17 more
commented

This exposes several problems:

  1. There is no catch for IllegalArgumentException in loadAsPersonalNetwork
  2. Something is done with the network name which creates something longer than a valid UUID
  3. I'm not sure the Central network should even be loaded as a personal network

I really wonder what string it tried to patch as a UUID, and what exactly caused it.

commented

Now I know what's hapening, whith the conflict management, it is trying to rename the personal network from <UUID> to <UUID>1, as it's conflicting with the default network. I'm unsure what the [SQLITE_BUSY] The database file is locked (database is locked) comes from though

commented

We might need to add another case in the gate creation conflict management, where it will throw an error when a network get's created with the same id as any UUID. so to say, UUID's should only be reserved to personal networks

And yes, we need to check if the name of the default network is valid as well.

commented

Now I know what's hapening, whith the conflict management, it is trying to rename the personal network from <UUID> to <UUID>1, as it's conflicting with the default network. I'm unsure what the [SQLITE_BUSY] The database file is locked (database is locked) comes from though

It's apparently trying to update a network name when it starts complaining about a locked database. It might just be that the IllegalArgumentException prevents the database from finishing what it's doing, and some code tries editing the database in that locked state.