WiIIiam278 / HuskHomes

The powerful & intuitive homes, warps, and teleportation suite
https://william278.net/project/huskhomes
Apache License 2.0
120 stars 78 forks source link

Player home lost #658

Closed buildin1 closed 2 weeks ago

buildin1 commented 1 month ago

It has been tested and found that there is a probability of player data loss when using SQLite and MySQL. Even if the server is shut down normally, sometimes user data cannot be saved properly. Currently, the latest version of Huskhome is being used, and this problem is very serious. Many server owners have encountered related issues, and feedback from players has affected the gaming experience

WiIIiam278 commented 1 month ago

Please provide details on how to reproduce and your setup if this is something you've experienced; if you have specific reproduction steps I'm able to look into this of course but "many server owners" is too vague and not actionable

hseermc commented 1 month ago

I'm running into this bug. it is very severe. all the players in my server lost their home when server restart or they Re-entry my server. They lost all the homes without the home which they first set.(sorry my poor English, i use bing translate Is it okay to fix it as soon as possible?

2534905003 commented 1 month ago

I also encountered this problem and hope to solve it soon, after solving it, I can use Alipay or PayPal to support you

CodeZhangBorui commented 2 weeks ago

The same problem occurs here.

By checking the database, I found that the last location data was saved at 2024/8/16 19:49:52. I performed a server restart task at 2024/8/18 20:30:00, and all the saved data was lost within nearly 49 hours.

There's an error reported at 2024/8/16 19:51:07 (After the latest positions in the database):

[19:51:07] [Craft Scheduler Thread - 675 - HuskHomes/ERROR]: [HuskHomes] Failed to set the offline position of shuatie
org.sqlite.SQLiteException: [SQLITE_BUSY] The database file is locked (cannot commit transaction - SQL statements in progress)
    at org.sqlite.core.DB.newSQLException(DB.java:1179) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.DB.newSQLException(DB.java:1190) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.DB.throwex(DB.java:1150) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.DB.ensureAutocommit(DB.java:1255) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.DB.lambda$ensureAutoCommit$2(DB.java:1226) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.SafeStmtPtr.safeRunConsume(SafeStmtPtr.java:142) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.DB.lambda$ensureAutoCommit$3(DB.java:1225) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.SafeStmtPtr.safeRunConsume(SafeStmtPtr.java:142) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.DB.ensureAutoCommit(DB.java:1223) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.DB.execute(DB.java:977) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.core.DB.executeUpdate(DB.java:1054) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.jdbc3.JDBC3PreparedStatement.lambda$executeLargeUpdate$2(JDBC3PreparedStatement.java:119) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.jdbc3.JDBC3Statement.withConnectionTimeout(JDBC3Statement.java:454) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.jdbc3.JDBC3PreparedStatement.executeLargeUpdate(JDBC3PreparedStatement.java:118) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:100) ~[sqlite-jdbc-3.42.0.0.jar:?]
    at net.william278.huskhomes.database.SqLiteDatabase.updatePosition(SqLiteDatabase.java:177) ~[HuskHomes-Paper-4.7.jar:?]
    at net.william278.huskhomes.database.SqLiteDatabase.setOfflinePosition(SqLiteDatabase.java:893) ~[HuskHomes-Paper-4.7.jar:?]
    at net.william278.huskhomes.listener.EventListener.lambda$handlePlayerLeave$7(EventListener.java:106) ~[HuskHomes-Paper-4.7.jar:?]
    at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[purpur-1.20.1.jar:git-Purpur-2062]
    at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[purpur-1.20.1.jar:git-Purpur-2062]
    at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[purpur-1.20.1.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]

It refers to:

https://github.com/WiIIiam278/HuskHomes/blob/588cc3f9900675393590c0584c302e721e04c218/common/src/main/java/net/william278/huskhomes/database/SqLiteDatabase.java#L177

At that time, two players (actually robots, which we allow) were offline at the same time:

[19:51:07] [Server thread/INFO]: hjfunny520 lost connection: [fakeplayer] Creator offline
[19:51:07] [Server thread/INFO]: shuatie lost connection: [fakeplayer] Creator offline

It is possible that the first player was not finished processing and then the second player was attempted to be processed while the table was locked.

Esacpe-beep commented 2 weeks ago

ctrl+c ctrl+v lol