Magic

Magic

190k Downloads

Bug during save

Nobodyno-boop opened this issue · 2 comments

commented

Reproduce: Disconnect during a magic load

bugreportmysql

Magic version: 10.8-9d589b4
Paper: git-Paper-637 (MC: 1.16.5)

the error:

[14:28:50] [Craft Scheduler Thread - 7242/ERROR]: �[31m Error saving player 4fd91c5a-2181-4154-9bdf-f9a337c25c39�[0m
java.sql.SQLException: No operations allowed after statement closed.
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[patched_1.16.5.jar:git-Paper-637]
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[patched_1.16.5.jar:git-Paper-637]
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[patched_1.16.5.jar:git-Paper-637]
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[patched_1.16.5.jar:git-Paper-637]
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73) ~[patched_1.16.5.jar:git-Paper-637]
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:82) ~[patched_1.16.5.jar:git-Paper-637]
	at com.mysql.cj.jdbc.ClientPreparedStatement.setString(ClientPreparedStatement.java:1754) ~[patched_1.16.5.jar:git-Paper-637]
	at com.elmakers.mine.bukkit.data.SQLMageDataStore.save(SQLMageDataStore.java:151) ~[?:?]
	at com.elmakers.mine.bukkit.magic.MagicController.doSaveMage(MagicController.java:4152) ~[?:?]
	at com.elmakers.mine.bukkit.tasks.SaveMageTask.run(SaveMageTask.java:22) ~[?:?]
	at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100) ~[patched_1.16.5.jar:git-Paper-637]
	at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) ~[patched_1.16.5.jar:git-Paper-637]
	at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.16.5.jar:git-Paper-637]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: com.mysql.cj.exceptions.StatementIsClosedException: No operations allowed after statement closed.
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[patched_1.16.5.jar:git-Paper-637]
	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85) ~[patched_1.16.5.jar:git-Paper-637]
	at com.mysql.cj.jdbc.StatementImpl.checkClosed(StatementImpl.java:338) ~[patched_1.16.5.jar:git-Paper-637]
	at com.mysql.cj.jdbc.ClientPreparedStatement.setString(ClientPreparedStatement.java:1751) ~[patched_1.16.5.jar:git-Paper-637]
	... 9 more
commented

Thank you for the very thorough bug report!

Looks like a race condition since saving and loading configs are both partially async they can collide. I put a synchronization lock in that I think should prevent this, it'll be in the next dev build. I was not able to fully test it myself, but I have high hope it will work.

commented

I am also hopeful, we have tested and it seems that it does not happen anymore even if it is rare cases.
Thanks for your work to the community !