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

Error / Data loss #906

Closed Strahilchu closed 3 years ago

Strahilchu commented 3 years ago

:information_source: Basic information

:beetle: Description

The server experienced a hard crash (I don't believe it was because of the plugin at all) However it lost all the data it had on players. After the server rebooted, everything else was normal, no rollback or anything. But AACH was like brand new. Could not restore player achievement data

:page_facing_up: Server logs

[05:48:07] [Paper Watchdog Thread/ERROR]: [AdvancedAchievements] Error while closing connection to the database: java.sql.SQLException: unable to close due to unfinalized statements or unfinished backups at org.sqlite.core.DB.throwex(DB.java:978) ~[patched_1.16.4.jar:git-Paper-325] at org.sqlite.core.NativeDB._close(Native Method) ~[patched_1.16.4.jar:git-Paper-325] at org.sqlite.core.DB.close(DB.java:248) ~[patched_1.16.4.jar:git-Paper-325] at org.sqlite.SQLiteConnection.close(SQLiteConnection.java:373) ~[patched_1.16.4.jar:git-Paper-325] at com.hm.achievement.db.AbstractDatabaseManager.shutdown(AbstractDatabaseManager.java:140) ~[?:?] at com.hm.achievement.lifecycle.PluginLoader.disableAdvancedAchievements(PluginLoader.java:174) ~[?:?] at com.hm.achievement.AdvancedAchievements.onDisable(AdvancedAchievements.java:64) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:265) ~[patched_1.16.4.jar:git-Paper-325] at org.bukkit.plugin.java.JavaPluginLoader.disablePlugin(JavaPluginLoader.java:415) ~[patched_1.16.4.jar:git-Paper-325] at org.bukkit.plugin.SimplePluginManager.disablePlugin(SimplePluginManager.java:516) ~[patched_1.16.4.jar:git-Paper-325] at org.bukkit.plugin.SimplePluginManager.disablePlugins(SimplePluginManager.java:502) ~[patched_1.16.4.jar:git-Paper-325] at org.bukkit.plugin.SimplePluginManager.disablePlugins(SimplePluginManager.java:495) ~[patched_1.16.4.jar:git-Paper-325] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.disablePlugins(CraftServer.java:435) ~[patched_1.16.4.jar:git-Paper-325] at net.minecraft.server.v1_16_R3.MinecraftServer.stop(MinecraftServer.java:770) ~[patched_1.16.4.jar:git-Paper-325] at net.minecraft.server.v1_16_R3.DedicatedServer.stop(DedicatedServer.java:704) ~[patched_1.16.4.jar:git-Paper-325] at net.minecraft.server.v1_16_R3.MinecraftServer.close(MinecraftServer.java:732) ~[patched_1.16.4.jar:git-Paper-325] at org.spigotmc.WatchdogThread.run(WatchdogThread.java:157) ~[patched_1.16.4.jar:git-Paper-325] [05:48:07] [Paper Watchdog Thread/INFO]: [AdvancedAchievements] Remaining requests sent to the database, plugin successfully disabled.

PyvesB commented 3 years ago

Hello @strahil211 ! 👋🏻

You seem to be using SQLite. Unless you've disabled DatabaseBackup in config.yml, the plugin should have created an achievements.db.bak file in its folder, simply swap that around with the main achievements.db file. You also probably do backups of your server on a regular basis, you can grab an older database file from those backups as well. 😉

Strahilchu commented 3 years ago

Hello @strahil211 ! 👋🏻

You seem to be using SQLite. Unless you've disabled DatabaseBackup in config.yml, the plugin should have created an achievements.db.bak file in its folder, simply swap that around with the main achievements.db file. You also probably do backups of your server on a regular basis, you can grab an older database file from those backups as well. 😉

All settings were default, the .bak did not help since the plugin had this error 10 hours after being installed. I think it should do a backup every few hours instead of one daily. It holds a lot of data and its important. Notice how it totally screwed me over :P

PyvesB commented 3 years ago

All settings were default

Are you sure about that? The stack trace indicates an error with SQLite, but the plugin by default uses a different database, H2. If you search the error message on Google, it's quite a common problem with SQLite, and I've got the feeling that everything would have been fine with H2 :)

I think it should do a backup every few hours instead of one daily.

Doing it every few hours whilst the server is running would not really be achievable. You can't copy the database whilst it's in use, as you may copy the database whilst it's in an inconsistent and create a corrupt backup. Looking at various SQLite resources on the Internet, the way to do things is to first lock the database, copy it over, then unlock it. If a player performs an action in game that requires direct access to the database (for example a non-cached statistic) right at that point, they will hit the lock and given how Spigot is single-threaded the whole server will freeze until the lock is released, which could be several seconds if the database is big. This would be terrible! If you know of any plugins that actually do an hourly backup, feel free to share them as I would be curious to know how they've implemented it, but I personally don't know of any and unfortunately can't think of a clean and efficient way of implementing what you're requesting.

Strahilchu commented 3 years ago

I leave my server running for a whole week without any restarts or stops, are you saying the plugin doesn't backup the data and after a whole week of people grinding if the server crashes all its data would be lost due to corruption? Also the config by default is set to h2 and I haven't touched a single thing in there so that's odd.

PyvesB commented 3 years ago

The author of this issue has been stirring things up on a third-party website (spigot.org) and engaging in dishonest claims (7:34pm UTC, between my first and second response):

Screenshot 2020-12-16 211845

Let's focus on two particular claims:

I literally couldn't find a way to get in touch

As you can see, they did actually find a way to get in touch several hours before then.

the lack of [...] support

As you can see, they have been receiving support, said support starting minutes after they first requested it.

Yes, the times on the GitHub messages are correct, I had the audacity to take a full 13 minutes to respond to this issue.

I spent time answering here and researching SQLite bug reports, had I seen the lack of appreciation, the misleading claims suggesting that I was unreachable and not providing support, and generally speaking the unwillingness to engage in a constructive manner, I wouldn't have put in this effort. There's not much to add here, as they say, "don't bite the hand that feeds you".

Note that I would be willing to reconsider this issue if there is a change in the way things are being approached.