Skip to content

Commit 4574904

Browse files
eklitzkeluke-jr
authored andcommitted
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.
1 parent 220bb16 commit 4574904

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/flatfile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ bool FlatFileSeq::Flush(const FlatFilePos& pos, bool finalize)
9292
fclose(file);
9393
return error("%s: failed to commit file %d", __func__, pos.nFile);
9494
}
95+
DirectoryCommit(m_dir);
9596

9697
fclose(file);
9798
return true;

0 commit comments

Comments
 (0)