Skip to content

Add save-all [flush] for region threading - #517

Closed
lewisgibson wants to merge 2 commits into
PaperMC:ver/26.2.xfrom
lewisgibson:save-all-flush
Closed

lewisgibson wants to merge 2 commits into
PaperMC:ver/26.2.xfrom
lewisgibson:save-all-flush

Conversation

@lewisgibson

@lewisgibson lewisgibson commented Oct 1, 2026 •

Copy link
Copy Markdown

Folia does not register /save-all, so a backup script that runs save-off, save-all flush and save-on gets "Unknown command" and archives region files that are still being written. The world has to be flushed to disk before it is archived.

This enables the command again. Each region section is saved by a task on the region that owns it, each player on its entity scheduler, and the level data and global saved data on the global region. The files are then flushed from a background thread, so no tick thread waits, and the reply ("Saved the game") is sent once they are on disk, including to rcon clients, which are answered when the command returns and so have to wait for it. As in Paper, a failure the server only logs while saving does not change the reply. An entity that is mid-teleport between regions at the moment of the save is not in that archive.

Tested on ver/26.2.x with 3 tick threads and 5 bots building in different regions of the overworld and the nether, each block change acknowledged by the server before the command:

  • 20 backup cycles, each running save-off, save-all flush over rcon, a copy of the world while the server keeps running with saving off, then save-on. In the copies 207205 of 207205 acknowledged blocks were present, every region file parsed, no region file changed while saving was off and every reply was Saving the game (this may take a moment!)Saved the game. Every fourth copy booted as a server (5 of 5). A flush took 0.7 to 1.7 seconds. The unpatched build answers "Unknown or incomplete command" and every one of its copies is missing every block.
  • kill -9 straight after the reply (0.07 to 0.1 s later), five rounds on one world, with save-all flush and with save-off first: nothing acknowledged was lost. The control, plain save-all, lost 690 blocks in its round, as expected.

This was done with AI (Claude Opus 5.5 and GPT Astra, high effort). I've reviewed it and tested it myself.

Folia does not register /save-all, so backup scripts bracketing a copy with save-off, save-all flush and save-on get Unknown command. See the patch for details.
@lewisgibson lewisgibson closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant