Fix possible data race when committing block files

It was recently pointed out to me that calling fsync() or fdatasync() on a new
file is not sufficient to ensure it's persisted to disk, a the existence of the
file itself is stored in the directory inode. This means that ensuring that a
new file is actually committed also requires an fsync() on the parent directory.

This change ensures that we call fsync() on the blocks directory after
committing new block files.
This commit is contained in:
Evan Klitzke authored and Luke Dashjr committed 2020-08-25 16:46:46 +00:00
1 parent 220bb16cbe
commit 4574904038
1 file changed
+1
+1
View File
@@ -92,6 +92,7 @@ bool FlatFileSeq::Flush(const FlatFilePos& pos, bool finalize)
fclose(file);
return error("%s: failed to commit file %d", __func__, pos.nFile);
}
DirectoryCommit(m_dir);
fclose(file);
return true;