[Resolved] Inventory reset doesn't always work
MrPranklez opened this issue · 26 comments
Thanks for taking the time to open a bug report!
Describe the bug
If "clear inventories" is enabled when players enter certain regions sometimes they won't get their inventories reset when they leave it (even when enabled in the config).
To Reproduce
Steps to reproduce the behavior:
I've only been able to reproduce it with the following steps:
- Enter a region (that has also been set up to clear inventory and reset inventories when they leave it)
- Disconnect from the server
- Reconnect to the server and you'll see the inventory remains even when you leave the region
Expected behavior
The inventories to be recovered when players leave the region (also when they go offline inside of that region)
Pastebin
config.yml
items.yml
Please complete the following information:
- Resource Version and Build Number: 5.1.0-b545
- Server Version Paper 1.16.5 build 444
Additional context
It also has occurred to some other players (not sure if these disconnected in the process), but I'm not sure how to replicate those
This is an error relating to this issue that was thrown in console at that time (error)
So I would say that this is simply just a bug with the v5.1.0 version as I recall fixing the pastebin error you linked and bugs with the RETURN option as well as doing major rewrites on WorldGuard in the latest official release (v5.2.1) so I would suggest updating and let me know if this resolves your issue.
Link; https://www.spigotmc.org/resources/itemjoin.12661/download?version=384212
Remember to remove your old ItemJoin.jar file
Also, P.L.E.A.S.E read the changelog as it contains major changes that will affect you when updating (it contains changes for both v5.2.0 and v5.2.1); https://github.com/RockinChaos/ItemJoin/wiki/Recent-Changes
I seem to be running into issues again with the following error in console:
23.02 11:20:35 [Server] WARN [com.zaxxer.hikari.pool.ProxyLeakTask] Connection leak detection triggered for org.sqlite.jdbc4.JDBC4Connection@7d61a204 on thread Craft Scheduler Thread - 812, stack trace follows 23.02 11:20:35 [Server] INFO java.lang.Exception: Apparent connection leak detected 23.02 11:20:35 [Server] INFO at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:100) ~[?:?] 23.02 11:20:35 [Server] INFO at me.RockinChaos.itemjoin.utils.sql.Controller.getConnection(Database.java:457) ~[?:?] 23.02 11:20:35 [Server] INFO at me.RockinChaos.itemjoin.utils.sql.Database.executeStatement(Database.java:66) ~[?:?] 23.02 11:20:35 [Server] INFO at me.RockinChaos.itemjoin.utils.sql.SQL.lambda$executeLaterStatements$0(SQL.java:57) ~[?:?] 23.02 11:20:35 [Server] INFO at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:99) ~[patched_1.16.5.jar:git-Paper-444] 23.02 11:20:35 [Server] INFO at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) ~[patched_1.16.5.jar:git-Paper-444] 23.02 11:20:35 [Server] INFO at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.16.5.jar:git-Paper-444] 23.02 11:20:35 [Server] INFO at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] 23.02 11:20:35 [Server] INFO at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] 23.02 11:20:35 [Server] INFO at java.lang.Thread.run(Thread.java:834) [?:?]
this causes players to lose their inventories and at times even duplicate certain items
Sorry for the issue, that's really odd.
Just to confirm, your config.yml is still the same? MySQL is set to false?
A connection leak shouldn't be triggered unless there is a major tps drop.
Okay so I think I narrowed down the issue, it seems to be related to local SQL, not MySQL so no need to answer that.
I wasn't able to replicate it myself but it should now be fixed in the latest snapshot and is safe to use.
Link; https://ci.craftationgaming.com/job/ItemJoin/682/
Remember to remove your old ItemJoin.jar file
Sorry about that, let me know!~
Alright perfect, apologies for not replying. I'll slap it on the server and see if I get any more issues, I'll keep you updated
Alright after some further testing and troubleshooting I managed to narrow down the issue. It happens when players teleport outside of the region to a different world. So let's say players are in the world "spawn" doing a parkour in a region that has been set up to clear inventories and return them. If they teleport to their home which is located in the world "world", their inventory will not be returned, instead they have an empty inventory
Please forgive me for this issue, so this is definitely not an SQL issue so switching to MySQL won't change anything. All data is stored in memory until the server is stopped or reloaded so if there is an accidental disconnect from the database it doesn't flush all the data.
I think I have tracked down the issue, I will have some additional information and hopefully a fixed snapshot shortly.
Alright this has been running for a few days now and there's still occurrences where players lose their inventories/get there inventories overwritten with the basic items in the items.yml. This time I don't come across any errors in console, nor are there any drops in tps, here is a timings report to reflect that.
I'm considering switching to mysql, but I'm afraid this might be even slower and cause more issues or is this not the case?
this is definitely not an SQL issue so switching to MySQL won't change anything.
Yeah I figured that's why I decided to do some more troubleshooting
Confirmed and replicated. Looks like I accidentally added a world check to the region identifier so it was comparing world
to world_nether
when worlds should be ignored when comparing region ids.
Seems to work properly now in the latest snapshot.
Let me know!
Link: https://ci.craftationgaming.com/job/ItemJoin/684/
Remember to remove your old ItemJoin.jar file
Sorry again for the issue!~
No need to apologize, this is an open-source project and free of charge. I'm glad you provide quick and kind support, event though it's not even mandatory!
Alright after a few extra days of rigorous testing, there is only 1 case where inventories don't get restored. This happens when a user disconnects from the server while in an active clear inventory/return region. If they only disconnect briefly, this doesn't happen it only happened in cases where a user would disconnect for more than an hour or so
So I have been bug testing this for about 8 hours and I cannot for the life of me replicate this issue.
What I tried;
- Logging out and back in inside the region and walking back out.
- Logging out waiting 3 hours and logging back in and walking back out.
- Logging out, stopping the server, starting it back up, and logging in to walk back out.
- Crashing the server, logging back in and walking back out.
- Logging out, reloading the server, logging back in, and walking back out.
Each of these results in the items being properly restored.
1.) Is there anything I can do that you have found which could replicate this issue every time?
2.) Has this so-far been a one-off issue with a single player or have there been additional reports?
Thank you for your patience!
This has been a single case issue, so it might just have been
I do have another issue that multiple players have reported. Sadly I haven't been able to replicate this one either myself. It seems that sometimes when regular players join the region and they leave afterwards. An older inventory is restored than the one they entered with.
Apologies that I can't provide any more in-depth steps to replicate the issue.
That's odd, when updating to the new builds, every time, I stopped the server, removed the database entirely and then removed the old jar and added the new jar. (and then obviously start the server again). I'll purge it again (regions have been closed off for a day) and let you know what happens in the upcoming days.
Ah I see, both these issues are related.
What is happening is that the old inventories which were not restored due to the prior bug are still stuck in the database file. The only option would be to /itemjoin purge
the database to resolve this and it wouldn't occur again since the bug has been resolved. The issue with that though is it would also purge existing (current) inventories as well for anyone residing inside the regions.
Let me look into this a bit further and see if there is a fix I can do to resolve issues with old inventories without purging the database.
Players still appear to get their inventories replaced with incorrect ones/cleared ultimately. Again, not quite sure where things are going wrong. I've added the database and there seem to be a few double entries for some users for some reason, maybe this could be the source of the issues?
Bingo! Thanks for the database I was able to figure out how to replicate it.
Easiest way to replicate it;
1.) Log into the server, walk into the region and log out.
2.) Reload the server via /reload
.
3.) Log in and walk a block forward.
4.) Reload the server.
Then it will duplicate (infinitely) given the steps are repeated the inventory data.
How are players doing it "legitly"?
Background -- The database data is SYNCED to the database every 30 minutes (if changes occured) so what happens is the player walks into the region and logs out, after 30 minutes their data is passed to the database.
When the player logs back in it thinks when they move they just entered a new region since they havent been there before (limitations of WorldGuard sadly) so it logs the inventory data again, then if they exit the region now, they are restored the wrong inventory OR if they log out again for 30 minutes it will end up restoring an old inventory when they exit the region for the third duplication.
Hope that makes sense, I am working on a fix for this now.
Latest snapshot now contains the duplication fix so it should now restore inventories properly, you will need to purge your database again when updating.
Link; https://ci.craftationgaming.com/job/ItemJoin/686/
Remember to remove your old ItemJoin.jar file
Let me know!~
I've had the snapshot running for a few days and I purged the db and everything but it seems there are still duplicate entries in the db for the same regions. Players are still experiencing the same issues as before. (included the new db file again)
database.zip
Okay so I think I figured it out. I hopped on--took me a while to find the parkour area and started messing around and realized that it is really easy to break if you join one of the parkours and log out, then immediately log back in.
It seems the issue is specific to parkour toggleLeaveRedirect
as with it disabled I am unable to replicate it. It seems that each time the player leaves while inside the region they get teleported while they are disconnected rather than once they rejoin the server, hense why the duplication happens as ItemJoin doesn't function for disconnected players. Which is also why I didn't catch it ealier as I thought it was an ItemJoin issue not a plugin compatability issue.
ItemJoin runs 99% of its methods ASYNC as to preseve memory and tps but when this is done it is a few ticks late than the main thread which is to say, by the time the ItemJoin method for WorldGuard is ran the player packet for disconnecting from the server has already ran and is therefore an offline player.
I changed the teleport method for WorldGuard regions to run SYNC so it seems to resolve the issues now.
Link; https://ci.craftationgaming.com/job/ItemJoin/687/
Remember to remove your old Itemjoin.jar file
Note you will need to purge & remove your database again.
Crosses fingers hoping for the best.
Sorry again for the issues, usually it doesn't take me this long to track down such a simple issue.
All good ;) All issues appear to be resolved, I'm glad I was able to point it and by doing so help make this plugin even better than it already is. Again, thanks for all the help!
This Issue has been resolved successfully!
Awesome! I am glad I was able to help.
Thanks for the donation btw, I really appreciate it!
As much as I wanted for this issue to be resolved I'm afraid some duplicate inventories popped up again.
After a few days of testing and using, some issues arose. My schedules weren't working for a few days making it so the server didn't restart for a few days. Today schedules have started working again and we had a few issues pop up again. Here is another copy of the database.
We had the server running for a solid 4 days and in those 4 days we had 0 issues, after the server restart we started to have issues
So since it seems to occur on restart I can estimate that it's an issue with the newly implemented Hikari API which handles the database.
I have simply dropped it as it has been causing way too many issues and I wrote my own API.
The latest snapshot should now resolve this issue.
Also may you please enable Debugging
in the config.yml, so that in the event that this happens again I will be able to get confirmation if it's a database issue. If the problem is resolved you can disable it again in a few days.
Link; https://ci.craftationgaming.com/job/ItemJoin/688/
Remember to remove your old ItemJoin.jar file
Do note; since I dropped Hikari, in order to fully delete the database.db data the server must be fully stopped so that Hikari is no longer committed to memory, then the database can be deleted.
Let me know!~