Map data do not flush to disk on regular autosave #372

Open
opened 2025-06-23 17:24:30 +02:00 by ac9607 · 4 comments
ac9607 commented 2025-06-23 17:24:30 +02:00 (Migrated from github.com)

Expected behavior

map data do not flush to disk with autosave

Observed/Actual behavior

Playerdata and chunk data are saved properly to disk with autosave, but map data only save to disk on proper shutdown. Map data can be saved with autosave on Paper. If the folia server crashes, all the map data will be lost.

Steps/models to reproduce

It can be reproduce everytime as server crash or unexpected power off

Plugin and Datapack List

None

Folia version

Folia version 1.21.4-DEV-dev/hard-fork@cd49d65 (1970-01-01T00:00:00Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)

Other

No response

### Expected behavior map data do not flush to disk with autosave ### Observed/Actual behavior Playerdata and chunk data are saved properly to disk with autosave, but map data only save to disk on proper shutdown. Map data can be saved with autosave on Paper. If the folia server crashes, all the map data will be lost. ### Steps/models to reproduce It can be reproduce everytime as server crash or unexpected power off ### Plugin and Datapack List None ### Folia version Folia version 1.21.4-DEV-dev/hard-fork@cd49d65 (1970-01-01T00:00:00Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT) ### Other _No response_
Circlepuller commented 2025-09-04 00:12:00 +02:00 (Migrated from github.com)

This bug is incredibly frustrating on servers that utilize map-based artwork. I'm really hoping that it can be addressed or some workaround can be suggested.

This bug is incredibly frustrating on servers that utilize map-based artwork. I'm really hoping that it can be addressed or some workaround can be suggested.
wg21655 commented 2025-09-27 16:09:38 +02:00 (Migrated from github.com)
https://github.com/PaperMC/Folia/blob/ver/1.21.8/folia-server/minecraft-patches/features/0001-Region-Threading-Base.patch#L8697-L8698 Maybe because this change causes the auto save to no longer work
SpoopyTim commented 2025-09-27 22:10:01 +02:00 (Migrated from github.com)

Found that running the following caused maps to save. Tried to be as unobtrusive to the overall logic as possible, hence why I'm targeting the DimensionDataStorage instead of the ServerLevel as a whole.

I am quite new to working with Folia so this may have unforseen implications regarding multithreading. It will probably be safer to run them inside the .globalRegionScheduler()

1.20 and below

Kotlin

(Bukkit.getServer() as CraftServer).server.overworld().dataStorage.save(true)

Java

((CraftServer) Bukkit.getServer()).getServer().overworld().getDataStorage().save(true);

1.21 and above

Kotlin

(Bukkit.getServer() as CraftServer).server.overworld().dataStorage.saveAndJoin()

Java

((CraftServer) Bukkit.getServer()).getServer().overworld().getDataStorage().saveAndJoin();

Likely to be caused by the mentioned patch file, although the original reason for disabling incremental saving in this circumstance seems to have been lost to time as the file has been renamed numerous times.

https://github.com/PaperMC/Folia/blob/ver/1.21.8/folia-server/minecraft-patches/features/0001-Region-Threading-Base.patch#L8697-L8698

Maybe because this change causes the auto save to no longer work

Found that running the following caused maps to save. Tried to be as unobtrusive to the overall logic as possible, hence why I'm targeting the `DimensionDataStorage` instead of the `ServerLevel` as a whole. I am quite new to working with Folia so this may have unforseen implications regarding multithreading. It will probably be safer to run them inside the `.globalRegionScheduler()` ## 1.20 and below Kotlin ```kt (Bukkit.getServer() as CraftServer).server.overworld().dataStorage.save(true) ``` Java ```java ((CraftServer) Bukkit.getServer()).getServer().overworld().getDataStorage().save(true); ``` ## 1.21 and above Kotlin ```kt (Bukkit.getServer() as CraftServer).server.overworld().dataStorage.saveAndJoin() ``` Java ```java ((CraftServer) Bukkit.getServer()).getServer().overworld().getDataStorage().saveAndJoin(); ``` Likely to be caused by the mentioned patch file, although the original reason for disabling incremental saving in this circumstance seems to have been lost to time as the file has been renamed numerous times. > https://github.com/PaperMC/Folia/blob/ver/1.21.8/folia-server/minecraft-patches/features/0001-Region-Threading-Base.patch#L8697-L8698 > > Maybe because this change causes the auto save to no longer work
wg21655 commented 2025-09-28 10:23:54 +02:00 (Migrated from github.com)

My temporary solution is to revert the line change mentioned above and add the following to the top of saveIncrementally()

if (doFull) {
    this.getChunkSource().getDataStorage().scheduleSave();
    return;
}

Similarly, only save DimensionDataStorage to avoid some unexpected problems

Also, if you get ConcurrentModificationException, you can add sync lock in collectDirtyTagsToSave() when looping this.cache

It has been running on my server for a few weeks, and the map data is auto saved normally. I haven't encountered any problems yet, but as mentioned above this is just my temporary solution

My temporary solution is to revert the line change mentioned above and add the following to the top of `saveIncrementally()` ``` if (doFull) { this.getChunkSource().getDataStorage().scheduleSave(); return; } ``` Similarly, only save `DimensionDataStorage` to avoid some unexpected problems Also, if you get `ConcurrentModificationException`, you can add sync lock in `collectDirtyTagsToSave()` when looping `this.cache` It has been running on my server for a few weeks, and the map data is auto saved normally. I haven't encountered any problems yet, but as mentioned above this is just my temporary solution
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Minecraft/Folia#372
No description provided.