enjin / Enjin-Minecraft-Plugin

GNU General Public License v3.0
10 stars 10 forks source link

Vote rewards and Donation Rewards are sending duplicate commands upon server restart. #15

Closed AvhiDhungel closed 5 years ago

AvhiDhungel commented 5 years ago

Every time the server restarts and a player logs in, the command for them to receive a reward that they received last is run again. The following error is thrown in console when it happens:

java.sql.SQLException: Values not bound to statement at org.sqlite.core.CorePreparedStatement.checkParameters(CorePreparedStatement.java:71) at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:100) at com.enjin.bukkit.storage.Database.addGroups(Database.java:189) at com.enjin.bukkit.listeners.ConnectionListener.lambda$updatePlayerRanks1$0(ConnectionListener.java:99) at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:84) at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

Additionally, this is also periodically thrown: java.lang.NullPointerException: null at com.enjin.shaded.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:136) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:118) ~[?:?] at com.enjin.shaded.json.JSONValue.writeJSONString(JSONValue.java:527) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter.writeJSONKV(JsonWriter.java:432) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:136) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:118) ~[?:?] at com.enjin.shaded.json.JSONValue.writeJSONString(JSONValue.java:527) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter.writeJSONKV(JsonWriter.java:432) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:136) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:118) ~[?:?] at com.enjin.shaded.json.JSONValue.writeJSONString(JSONValue.java:527) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter.writeJSONKV(JsonWriter.java:432) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:136) ~[?:?] at com.enjin.shaded.json.reader.JsonWriter$7.writeJSONString(JsonWriter.java:118) ~[?:?] at com.enjin.shaded.json.JSONObject.writeJSON(JSONObject.java:127) ~[?:?] at com.enjin.shaded.json.JSONObject.toJSONString(JSONObject.java:74) ~[?:?] at com.enjin.shaded.json.JSONObject.toString(JSONObject.java:215) ~[?:?] at com.enjin.shaded.jsonrpc2.JSONRPC2Message.toString(JSONRPC2Message.java:253) ~[?:?] at com.enjin.shaded.jsonrpc2.client.JSONRPC2Session.send(JSONRPC2Session.java:599) ~[?:?] at com.enjin.rpc.mappings.services.PluginService.sync(PluginService.java:103) ~[?:?] at com.enjin.bukkit.sync.RPCPacketManager.sync(RPCPacketManager.java:115) ~[?:?] at com.enjin.bukkit.sync.RPCPacketManager.run(RPCPacketManager.java:61) ~[?:?] at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:84) ~[patched_1.14.4.jar:git-Paper-192] at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) ~[patched_1.14.4.jar:git-Paper-192] at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.14.4.jar:git-Paper-192] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

Server is on paper-192 (MC:1.14.4) Plugin version: 3.5.11

Favorlock commented 5 years ago

Thanks for the report. I've been investigating this issue the last week and you may have provided the missing link. I was aware of the NullPointerException but not the SQLException, so that may be what is causing the problem. Will get back to you if I believe I have a fix or need additional information.

Favorlock commented 5 years ago

I've attached a development build where I've synchronized each database method such that the relevant prepared statement can only be accessed when it is not in use. This should resolve the SQLException I believe. Let me know if this resolves the issue.

EnjinMinecraftPlugin.zip

AvhiDhungel commented 5 years ago

Thank you for the quick response! I've started using the new jar. Don't see any errors on console as of yet and no duplicate rewards command seems to have been run so far. I will update again after giving it some time.

Favorlock commented 5 years ago

Ok, thanks! Let's hope that did the trick. :)

AvhiDhungel commented 5 years ago

Hey there! I'm no longer seeing any of those errors, but donations from donationcraft seem to not be running commands to console anymore.

Favorlock commented 5 years ago

I’ll need you to enable debug mode, let the plugin run for 20 minutes, and then generate an Enjin report and send me the generated zip file. Additionally, it could be helpful if you can send the enjin.db and some screenshots of the package setup you have on the website.

Favorlock commented 5 years ago

Ok, so appears I made a rookie mistake and forgot to assign the result of a method call after making some changes recently. So those errors you were experience may or may not be fixed, but we'll find out now that it's capable of processing the sync data again. If you wouldn't mind testing this build out and confirming the issues in question above are resolved. I've confirmed that commands are now running again.

I've also added some extra validation steps for some things, so if something fails only that part fails and should allow other parts to still function as expected.

EnjinMinecraftPlugin.zip

Sikatsu commented 5 years ago

Seem to be getting this error using the devbuild above:

https://pastebin.com/dC4Pmj4C

Favorlock commented 5 years ago

Seem to be getting this error using the devbuild above:

https://pastebin.com/dC4Pmj4C

And no stack-trace below that? If not you can use the build attached to this reply and the full stack trace should be printed.

Also, if you could zip and upload the enjin.db file that would be appreciated. After sending that you should delete it to see if it's an issue with some of the stored data from a previous build.

EnjinMinecraftPlugin.zip

Sikatsu commented 5 years ago

Here is the .db file: https://www.dropbox.com/s/0o7hdt5i213p0e1/enjin.db?dl=0

And here are some more logs on the latest build: https://pastebin.com/JF3KH4vc

Favorlock commented 5 years ago

Thanks, so I definitely see an invalid db entry, so I'm adding some extra steps to the fetch query that will remove any invalids from db, however, I don't think it's likely that these invalids will continue to be inserted since the prepared statements are synchronized, thus concurrency issues shouldn't be a problem now. I'll attach a build for you.

Did you delete the db file after you sent it to me? If so, did the issue persist?

EnjinMinecraftPlugin.zip

Sikatsu commented 5 years ago

Hey, updated the plugin and it seems commands are being triggered again: http://prntscr.com/paonr0

I didn't delete the .db file, since I forgot too. Is that still required now?

Favorlock commented 5 years ago

Glad to hear! You don't need to delete the db file. I added in some handling that should prevent invalid data from being stored. If you're able to get back to me in a day or so to let me know if everything is still running smoothly that would be appreciated.

Sikatsu commented 5 years ago

Everything seems to be well so far.

Favorlock commented 5 years ago

Ok. A new release has been posted at https://github.com/enjin/Enjin-Minecraft-Plugin/releases/tag/v3.5.12 and will be uploaded to the spigot forums soon.