Autorank

Autorank

380k Downloads

Times being reset/lost

GrahamJenkins opened this issue ยท 16 comments

commented

I've been trying to identify exactly what is causing it, but it seems that some or all players are having their times partially reset in what feels like some sort of race condition. Regardless of whether or not player time is naturally accrued or manually added via DB (and each server reloaded to be sure) players are still losing time, going to global levels lower than what the users have accrued on individual servers. I'm unable to identify what determines the remaining time, but have seen it happen at least once every couple of days for one or multiple users.

One suspicion I had was that (#229) my database was being locked up or was inaccessible (it's running on a separate server but has good connectivity) and that the issue could happen if AR was attempting to pull global time, add it to current playtime, and then update the DB. if AR couldn't access the DB and assumed 0 for global time, then wrote that into the DB the next time it was able to access it.

If anything, while this wouldn't necessarily fix the issue, but doing an update once per minute as follows shouldn't have any conflict with database connectivity:
UPDATE autorank SET time=time+1 WHERE uuid IN ('uuid1', 'uuid2', 'uuid3');

Additionally, storing accrued time locally in the case of DB issues could avoid this type of issue.

Thanks!

commented

Side note, I'm not experienced in java/bukkit dev, but have a significant background in php/mysql development, if you want a hand in that I'd be glad to help.

commented

What do you exactly mean by 'race condition'?

commented

Race condition being when two sources try to update the same resource, in this case DB. As mentioned in another ticket, a potential race condition would be:
User is logged in on server A, admin issues /ar gadd on another server (or via SQL), server A hits update threshhold, overwriting DB time if it hasn't checked the DB for most recent times yet.

This may or may not be an issue depending on how and when AR checks for time updates, especially when players are actively logged in.

commented

Will do, looking forward to it. So in the ideal case any DB updates should be automatically picked up by AR on each server.

commented

Ahh, I get the problem. I think I can fix this pretty easily. I'll work on it and have a new build out for you soon to test (probably tomorrow). Please report back with your results then, you'll be my test bunny!

commented

Yes, that's what I'll be working on ;)

commented
commented

Reloads without any errors, I'll keep an eye on it and update if anything comes up.

If I were to pull the source code what would be the best way to do my own builds? I'm not familiar with building java yet but know enough code/git to get into trouble. :-) Any links that would walk me through pulling code/running builds on one of my servers?

commented

If you wanna alter the code yourself, you're going to have to download an IDE. You'll need to fork this project, pull it to your IDE and alter the code. You'll be able to 'export' your code from the IDE to a .jar file which you can run on your own server.

commented

@Staartvin Well we ran stable for several days and I logged in today and saw that several players had lost global time again. These numbers went from matching to way off overnight, I've noticed two users that had this happen, I know one has been online for almost the last day, the other fairly active, so I'm wondering if it has anything to do with players online for a long period of time somehow.

http://gyazo.com/a0176d7c2a9121176eb2878df843af7d

commented

[06:56:40 ERROR]: Could not pass event PlayerJoinEvent to Autorank v3.5.1-Dev-382
org.bukkit.event.EventException
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot.jar:git-Spigot-952179b-e87122e]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-952179b-e87122e]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-952179b-e87122e]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.PlayerList.onPlayerJoin(PlayerList.java:263) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.PlayerList.a(PlayerList.java:148) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.LoginListener.b(LoginListener.java:109) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.LoginListener.c(LoginListener.java:41) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.NetworkManager.a(NetworkManager.java:159) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.ServerConnection.c(ServerConnection.java:82) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:785) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623) [spigot.jar:git-Spigot-952179b-e87122e]
at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526) [spigot.jar:git-Spigot-952179b-e87122e]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_75]
Caused by: java.lang.NullPointerException
at me.armar.plugins.autorank.listeners.PlayerJoinListener.onPlayerJoin(PlayerJoinListener.java:35) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_75]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_75]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_75]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_75]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot.jar:git-Spigot-952179b-e87122e]
... 14 more

commented

Digging into error, it seems that it's running on all servers other than my main factions server. Disabling advanced config and testing again.

commented

Okay, so I'm building a new version for you with a debug message. You'll have to turn debug on, and let players join.

commented

It might be handy to communicate via Minecraft/Skype/TeamSpeak, whatever you prefer, as that is a bit faster.

commented

Added on skype I believe, added and I'm still getting the error, for some reason it seems like it may be conflicting with mcmmo, disabled that and it loaded. Re-enabled and it broke again.