Jump to content

Why aren't config files force synced to disk?


warjort

Recommended Posts

It seems to be a common problem that when somebody loses power to their computer that some of the config files get corrupted. e.g. the most recent

https://forums.minecraftforge.net/topic/113418-modded-world-not-loading-version-1165/

My question is why aren't the config files forced synched to disk? They are just closed. Using a Closeable here:

https://github.com/TheElectronWill/night-config/blob/1d678751747451e3a8458cf12d0ced21b84ebcad/core/src/main/java/com/electronwill/nightconfig/core/io/ConfigWriter.java#L87

It is my understanding that this will just leave the data in the buffer cache, and doesn't guarantee it will be physically on disk. I could be wrong about that and it might depend on the OS?

 

Minecraft uses the following logic where file is a FileChannel - see net.minecraft.world.level.chunk.storage.RegionFile

         try {
            this.file.force(true);
         } finally {
            this.file.close();
         }

 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Yes, that is what I thought.

You can Channel.force() or FileDescriptor.sync() to ensure the data is written to disk.

Why isn't this done for config files to avoid corruption if you have things like power outages?

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

I am not saying it is a silver bullet, but it does decrease the time the config files are held in the buffer rather than on disk, making it less likely to happen.

People with large amounts of free memory can have large buffer caches that are not flushed for a while. 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.