Does /save-all obey max-auto-save-chunks-per-tick?

Darkhand

New member
Feb 15, 2022
3
0
1
Hello!

I haven't been able to find a good way to create hot-backups of a server/world that are both file-safe and don't block the main thread. Everything I've found online says to avoid /save-all like the plague, but I haven't been able to confirm if Paper uses its async chunk saving routine when calling /save-all.

Backing up the world while the server is running under normal operation creates the potential condition of copying a chunk file while it's being written to, rendering the backup file incomplete/corrupted. In a perfect world, one would turn off chunk save queuing with /save-off, flush chunks to disk with /save-all, perform the backup, then re-enable the queue with /save-on. But unless /save-all saves queued chunks using Paper's graceful async method, this will typically cause a lag spike on the server. The only other failsafe solution is to back up the world while it's offline.

tldr; Does the /save-all command obey max-auto-save-chunks-per-tick and/or use Paper's async chunk saving routine? And if not, is there any reason it couldn't?
 
Last edited:

electronicboy

Administrator
Staff member
Dec 11, 2021
85
6
18
8
save-all is designed to save the entire world to the disk right now, chunks will use the async IO stuff for saving as that's baked in but the max-auto-save is for auto saving, it would be somewhat stupid if save-all didn't actively save all chunks given that that is what it's supposed to do

save-off
wait for 30 seconds for the queue to flush
do backup
save-on

noting that save-off isn't 100% foolproof towards preventing data being mutated on the disk; there were plans to have some command which would basically block the execution until the queue is drained for stuff like rcon to use, but that's some ways away
 

Darkhand

New member
Feb 15, 2022
3
0
1
save-all is designed to save the entire world to the disk right now, chunks will use the async IO stuff for saving as that's baked in but the max-auto-save is for auto saving, it would be somewhat stupid if save-all didn't actively save all chunks given that that is what it's supposed to do

save-off
wait for 30 seconds for the queue to flush
do backup
save-on

noting that save-off isn't 100% foolproof towards preventing data being mutated on the disk; there were plans to have some command which would basically block the execution until the queue is drained for stuff like rcon to use, but that's some ways away
Thanks! That's a good workaround, just turn off queuing and wait for whatever your autosave interval is before doing the backup, then turn it back on. Your only concern then is crashing during that wait period, but that's pretty darn minor at that point.

I would think you'd want to set your max-auto-save-chunks-per-tick to something your machine can handle without lag, even if it were autosaving at that max every single tick, no? So save-all could basically take whatever's in the save queue and push it all immediately, but obey the same rate limiter as autosave while doing so... say you had 400 chunks to save sitting in queue and your max is set to 10 per tick... save-all would immediately start flushing to disk at 10 chunks per tick, saving everything in 40 ticks/2 seconds.

Unless I'm totally misinterpreting the timing of the existing autosave system and it's already saving much more frequently than I'm thinking, which is always possible. :)
 

electronicboy

Administrator
Staff member
Dec 11, 2021
85
6
18
8
paper saves chunks which haven't been saved longer than the save interval allows up to X amount of chunks, up to the amount configured, per tick
what you're describing save-all should do is what the server pretty much already does (just, without the means to say override the timer to make stuff save sooner), save all is designed to save all unloaded chunks NOW, and there is pretty much 0 reason to change that which doesn't start getting into naunces which already exist, i.e. there is no sane means to wait for the command to finish anyways, so you're basically shooting in the dark anyways
 

Darkhand

New member
Feb 15, 2022
3
0
1
paper saves chunks which haven't been saved longer than the save interval allows up to X amount of chunks, up to the amount configured, per tick
what you're describing save-all should do is what the server pretty much already does (just, without the means to say override the timer to make stuff save sooner), save all is designed to save all unloaded chunks NOW, and there is pretty much 0 reason to change that which doesn't start getting into naunces which already exist, i.e. there is no sane means to wait for the command to finish anyways, so you're basically shooting in the dark anyways
Got it, yep sounds pretty close to ideal as-is. And if save-all dumps all chunks and not just queued ones, you're right that save-all is the wrong command for what I'm looking to do... It would need to be a new one like save-queued or something, to drop the timer to zero and immediately start saving out the chunks in queue, then somehow detect when that's complete.

For now, waiting for the autosave interval sounds like the way to go! Thanks much
 
Last edited: