3 ms·
You have to call fsync after you write the temporary file to avoid data corruption unless btrfs is mounted with the flushoncommit option. Without it btrfs flush
by Comevius 5y ago
You have to call fsync after you write the temporary file to avoid data corruption unless btrfs is mounted with the flushoncommit option. Without it btrfs flushes, but without waiting for completion.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8d875f95da43c6a8f18f77869f2ef26e9594fecc https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...
I guess an approach like SQLite's WAL is faster for this.
https://www.sqlite.org/wal.html https://www.sqlite.org/wal.html
The only thing to keep in mind is that you can cause SQLite's WAL to keep growing with concurrent writes, as the checkpointer can checkpoint the WAL, but cannot overwrite it. There is a WAL2 branch of SQLite that tries to fix this.