PyvesB / advanced-achievements

:fireworks: Popular plugin that adds unique and challenging achievements to Minecraft servers.
https://www.spigotmc.org/resources/83466
GNU General Public License v3.0
199 stars 215 forks source link

Database reset on player quit #467

Closed Leomelonseeds closed 5 years ago

Leomelonseeds commented 6 years ago

Recently (or not), it seems that almost everyone is experiencing playtime calculation issues. Their playtime either is not tracked at all, or even goes down. One player reported that his playtime stayed at 4 hours even though he had played for tens of hours (can confirm), and sometimes it rose to 6, but when he disconnected and came back a while later, it was back at 4.

Config: https://pastebin.com/pSCQP40u

Thank you in advance, I appreciate your activeness and all the work you have put into this amazing plugin :D

PyvesB commented 6 years ago

Hello @Leomelonseeds,

Sorry for the slightly delayed response. I have just tested your configuration on my server, but unfortunately I am not able to reproduce the issue. Is this the only category for which you are having data consistency issues? Are there any errors or warnings in the console? Are you using the latest version of the plugin?

Do your players happen to be in creative or spectator mode, or are they AFK for long periods? In those cases, the time will not increase.

Cheers,

Pyves

Leomelonseeds commented 6 years ago

Maybe it's an issue about the database? Because one of my players has played (non-afk) for 8 hours and their time hardly increased.

It seems like the achievement for 1 hour always works, but higher up and it starts being glitchy.

PyvesB commented 5 years ago

Could you provide me with the name of one player for which these achievements are not working properly? I'll then add some extra logs to the plugin for that player (adding to all players would just generate too much noise) and we will then have more information when he plays for several hours without the time increasing.

PyvesB commented 5 years ago

@Leomelonseeds are you still facing issues with the time calculations?

Leomelonseeds commented 5 years ago

Yes I am. One player reported that the achievement said he hadn't even joined yet.

The other player's name is BorterSnor, sorry about not replying earlier.

PyvesB commented 5 years ago

I'll prepare a custom jar with that player's name in the coming days, stay posted. 😉

Leomelonseeds commented 5 years ago

Thanks! :O

PyvesB commented 5 years ago

Here's a custom version that contains two additional logs statements starting with [BORTERSNOR-DEBUG] for player BorterSnor in the played time processor. Not sure how helpful they'll be, but at least they will allow us to rule out obvious problems with the code. AdvancedAchievements.zip

Leomelonseeds commented 5 years ago

Thank you so much! I will be putting the results back to you tomorrow :D

Leomelonseeds commented 5 years ago

latest.log

There ya go. I looked for the text [BORTERSNOR-DEBUG] with notepad++ and it seems like it sometimes goes up, sometimes down... wtf?

PyvesB commented 5 years ago

Does the configuration file you shared really correspond to this log file? The configuration specifies PlaytimeTaskInterval: 120, whereas the logs seem to indicate that the task is running every 600 seconds.

Leomelonseeds commented 5 years ago

Sorry, I might have changed it due to lag issues. Regardless, playtime should count normally...

PyvesB commented 5 years ago

Okay, that makes sense. I've attached a version with a bit more logging, if you could attach latest.log like last time it would be great!

AdvancedAchievements.zip

PyvesB commented 5 years ago

@Leomelonseeds any luck with the above?

Leomelonseeds commented 5 years ago

Crap... I forgot about this issue again sorry. I will have results ready in a few hours

Leomelonseeds commented 5 years ago

Hello. It seems that BorterSnor has quit Minecraft and I could not convince him to come back on (I am big sad) Could you please change the username to leprechaunsRUs?

PyvesB commented 5 years ago

Here it is: AdvancedAchievements.zip

Leomelonseeds commented 5 years ago

Thank you very much. Results by tomorrow (I promise this time xD)

Leomelonseeds commented 5 years ago

Ok I cannot keep my promises omg

Anyways here is the log file. Sorry, OldCombatMechanics is spamming console errors. To find the playtime simply Ctrl+F and search for "Updating played time." I believe the glitch is that whenever someone else gets another playtime achievement it resets it for everyone else.

latest.log

PyvesB commented 5 years ago

I had still kept BorterSnor's in the log checks, so I'm missing some of them, here's the fixed version: AdvancedAchievements.zip

Leomelonseeds commented 5 years ago

Sorry for the big file again but just use crtl+f like last time.

latest.zip

PyvesB commented 5 years ago

As indicated by the [LEPRECHAUNSRUS-DEBUG] Sending value ... messages, the plugin is trying to do the right thing, but the values don't seem to get persisted to the database above ~1M for the play time. Therefore, when the player reconnects, most progress is lost.

This seems to indicate that there's an issue with the database. Could you please try dropping the playedtime table? Also, what version of MySQL are you running?

Leomelonseeds commented 5 years ago

Ok, it seems like many many more achievements are broken. I will opt back to an Sqlite database and report back.

PyvesB commented 5 years ago

It might be an issue with the MySQL setup, possibly auto-commit disabled or something similar. Let me know if it works better with SQLite; you can also try out H2, it doesn't require any setup on the server side.

Leomelonseeds commented 5 years ago

Welp, still not working with SQLite. I will send logs later but my current theory is that the data base might contain too many rows.

Leomelonseeds commented 5 years ago

I believe I have found how to replicate the issue. Whenever you relog it resets the playtime to exactly 3.9 hours apparently. It does this with almost all other achievements as well. Maybe there's some kind of barrier related to database storage?

PyvesB commented 5 years ago

Could you please try removing all plugins apart from Advanced Achievements and see wheter the issue is still happening? Maybe there's some sort of conflict.

By the way, which Minecraft version and Spigot/Bukkit version are you using?

Leomelonseeds commented 5 years ago

Using mc 1.13 running paperspigot build 488.

I've been doing some debugging for this problem and have concluded that there is only one possiblity: the plugin is writing erroneous values to the database.

We have tried in both MySQL and SQLite, so this couldn't possibly be a database error. Besides, the glitch happens only when players leave and join again, and there's no way the database could detect that. So it's not a threshold problem.

Since the plugin writes and retrieves data from the database, the only possible conclusion is that the plugin is writing something to the database when players leave/join (not sure which) and it's wrong data.

Is there any method that does this? It's been happening to other achievements as mentioned above. All reset to an earlier value when relogging.

I have not tried on a local server with just the aach plugin yet, but will soon.

Leomelonseeds commented 5 years ago

It seems to be working a bit better now, will report back after investigating players more.

PyvesB commented 5 years ago

How are things going @Leomelonseeds ? Have you had a chance to try on a local server with just Advanced Achievements?

Leomelonseeds commented 5 years ago

I believe the issue has been resolved with the H2 database. I've had to reset all achievements, but I am happy to report that h2 database seems to cause no lag whatsoever compared to SQLite and MySQL. You should make this the default database :P

PyvesB commented 5 years ago

Okay, good to hear! As I haven't been able to reproduce any of the play time and statistic persisting problems with SQLite/MySQL and haven't heard about any other users having similar issues in recent months, I think we should finally close this. Feel free to open new issues if you have any other questions about the plugin. 😉