Sophisticated Backpacks

Sophisticated Backpacks

89M Downloads

Save backpacks in separate files or just in player inventory to avoid deleting peoples items on every crash....

GotoFinal opened this issue ยท 10 comments

commented

Currently whenever server crashes there is big chance for the backpacks to just void a lot of content (playing dawncracft 1.18.2) and i noticed all backpacks are stored in single global files, this makes everything very problematic, as even with backups i cant restore a single backpack as everything is bundled together. Storying everything as separate files or just directly in player file would make everything much more stable

commented

Could you explain to me why you would want to restore single backpacks? Yes crashes can cause mc to not save all the data and in that case it may happen that it won't save backpack data, but I don't understand why restoring all backpack contents from backup is bad vs having to restore individual backpacks.

commented

Because depending on when people logged in/out not everyone was loosing their items, so resting global backups would put everyone behind including people who didnt lose anythoing.
I solved the issue on my end in rather bad way of having auto save on backpack closing and every few minutes with some limter to not save too often...
but that also causes issues as always everything must ba saved at once, this can cause smaller lag spike when there is many players with many backpacks, as even tho only 1 small backpack changes I need to save MBs worth of data of everyones backpacks, often even some old and forgotten ones.

commented

So you had some people lose their items while others didn't lose them? I have never heard of that one, only of all backpacks losing contents at the same time.
And you really shouldn't need to do any kind of special autosave on backpack closing, the backpacks are used in thousands of modpacks with so many players playing with these and I have never heard of anyone needing to do more than regular backups just in case server crashed in a way where it doesn't save backpack contents.

commented

It's normal, you can't lose progress when offline and with just big group of friends it's hard to always be there ready to restore something, so some players lose progress and logout while others join and play more making new progress. (~20 people, multiple timezones)
Having backups in separate files/db/etc where not everything must be saved/loaded at once would improve both resiliency and performance on save. Single continuous file for all data of all players is just not scalable, especially when some modpacks include backpacks in drops or mobs, as the data just grows.

Overall I don't really care much if you want to improve on that or not, it's just a suggestion, each time I play some modpack with friends I just fix a lot of mods myself and do a bunch of reports and sometimes PRs as there is always a bunch of broken stuff no matter the popularity, dawncraft was probably one of the worst so far so I would not be surprised if that issue was made worse by other mods, and my solution with saving on close was just a dirty hack to make my friends not give up on playing due to loosing progress every day not something I expect the mod to have.

commented

You will absolutely lose progress even when offline if that crash causes backpack contents to not save because in that it means loss of all backpack contents.
That's why I am confused how you could only lose progress for some of the backpacks. Perhaps some mod is trying to be "clever" and not allows continuous saving to happen and then doesn't save when server shuts down.

commented

if that crash causes backpack contents to not save because in that it means loss of all backpack contents.

well depends when the crash happens, imagine player A joining, doing progress, save happens at some point, leaving, then B joins makes progress, crash happens, so nothing from B time is saved, then A joins back and continues playing not even knowing anything happened.

commented

well what I am trying to say is that backpack contents always get saved as a whole whether the player played or not doesn't matter and because of that if the crash causes this save to break it doesn't save any contents so player A's backpack contents wouldn't be there either. Unless you meant that you are doing restore of that data somewhere in that process and because of that the player doesn't notice anything happened.

commented

No... ok, again, step by step with timeline in simplest case:

  • 01:00: Server saved, everything is correct, no data was lost so far
  • 01:20: Player A joins and start collecting stuff
  • 02:00: Server crashed, some of his recent changes were not saved, for example him moving the items from base to backpack
  • 02:20: Server started again, nothing after 01:50 was saved and because player was moving items he either duplicated or lost a lot of them because world and players are saved differently on many modpacks, maybe thats the part is missing. No idea even if its vanilla or some mod.
  • 02:40: other players join and make own progress, i can no longer restore anything for Player A because other people are active

I'm very used to these differences in saving from many modpacks, where player data is saved much more often than the worlds, making any crash a source of lost items or duped items depending if player was moving iterms from or to his inventory.
Something was also causing some backpacks to go empty, but never found what, maybe something changes the ID like upgrading it or something else, and then again it get saved in inventory with new ID but after crash the actual content is still assigned to old ID.

But anyways, it happened, was annoying, and main point is still:
Having backpacks in separate files/db/etc where not everything must be saved/loaded at once would improve both resiliency and performance on save. Single continuous file for all data of all players is just not scalable, especially when some modpacks include backpacks in drops or mobs, as the data just grows.
Loading and saving 300 backpacks when maybe like 10 are used is just bad.

commented

Well you seem to be the only one suggesting that this is so bad so I am trying to find out more.
And all I am getting it seems is that you get very regular crashes on your server with various things being / not being saved and I have to say that working with the fact that things constantly crash isn't something that I want to code for. Those crashes really need to be solved so that other stuff can work.
Even if I split the contents into multiple files based on what you're saying the backpack contents wouldn't save at times and things would disappear / get duplicated so I actually fail how that is any kind of solution.
Yes the backpack contents file can get pretty big, but there's no issue with that as far as I can see, I would have heard about performance issues related to that years ago. But if you have performance issues with that please attach spark profile or something similar that shows how that is affecting your server.

commented

well if you dont see it as issue I will just close it, not really want to use up my time arguing about that more, for me its just basic good practices when creating software, 1 bad person, 1 bad mod, 1 bad issue and whole file might get unusable. In mc community most of people just don't care and I'm used to that, dawncraft had a mod consuming 10ms per tick and no one complains, even tho after 1h of fixing it was 0.1ms (blood and madness) and suddenly playing with 20+ people is possible. But people will just blame everything on Java and that its just "heavy pack".
Spark is also very hard to showcase lag spikes as it averages out too much, but main issue is that the server ofc no longer exists, as typical mod server and people finish the progress or get bored.

Anyways, have a nice day, will close it for now as don't want to argue about it all day.