Magic

Magic

190k Downloads

data/automata.yml wiped out completely after server shutdown

7-75 opened this issue ยท 4 comments

commented

I still can't narrow down the exact reasons why but it seems as if when I shut down the server (in certain instances) the data/automata.yml file is wiped out completely clean.

My main guess is that it happens when I accidentally (sadly has happened quite some times by mistake) press ctrl+c on the console (if that makes any difference) and the process stops.
I'll be trying to see if that's the exact case but it's really a huge problem as every time I have to load a backup and stop completely the server.

commented

:(

I do my absolute best to prevent this from happening, even if your server crashes.

Magic first writes out the new file to a temp file (automata.yml.tmp)
Then it renames the existing file to a backup file (automata.yml.bak)
Then finally it renames the temp file to the real file (automata.yml)

The idea being the chances of something interrupting the file rename (generally an atomic and near-instant action) are very slim.

Do you ever see any errors in your logs? Could you search for Error saving data file in your logs (if you save them), or watch out for that in the future if this happens again?

Other than moving to database storage (which would be great, but unlikely to happen soon) I'm not sure that I can make this process any safer, unfortunately.

Something unexpected may be happening, but I can't think of what it could possibly be.

commented

Can't find that message in the logs.. maybe has to do with write permissions but hey, thanks for the help

commented

Have you still been seeing this problem?

I tried my best to reproduce it, and the plugin does everything it can to save backups of the file and make sure it's not being written to directly. I'm at a loss.

commented

I've added some additional safety measures, it will now save permanent backup files any time it detects that the main file has reduced in size.

I'm hoping this prevents further problems.

I did have this happen on my own dev server, I'm still not really sure how though.

Going to close this for now.