New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offer durable file writing functions #87
Comments
My personal take right now is safe defaults are better, even if they are much slower due to the fsyncs and moves. And ideally the docs should point out things like "if you do not need durability, use this other function which is much faster". Also relevant for atomic moves (and performance) is whether the source and target are on the safe file system (overwise the |
The atomic move issue is probably the biggest question mark about this for me. AFAICT, the only way to reliably implement this is to create a temporary file in the same directory as the target file and then move it. However, in the case of program crashes/SIGKILLs/etc, there's a possibility that the file could be left behind, meaning that this change doesn't just trade performance for durability, but also introduces slight externally-visible semantic changes. |
I found another very useful thread that discusses these issues, and particular wheter |
Just stumbled on this ticket. It seems like it can be closed, no? |
I think so |
rio
should offer file writing functions that are durable.That involves
fsync()
ing the file itself after writing and beforeclose()
, andfsync()
ing the directory that contains the file. It also involves failing hard on errors infsync()
, as retrying fsync has no effect.Sources for fsyncing the directory:
See also:
linux-fsdevel
mailing listrename()
isn't enough to ensure durabilityNote it may not be possible to provide durable variants for all operating and file systems, but these functions should be as durable as they can be.
We should also discuss whether durability should be the default in
writeFileBinary
andwriteFileUtf8
.In general,
rio
should expose durable and non-durable variants of file writing operations.The text was updated successfully, but these errors were encountered: