rocksdb

Why does rocksdb need to perform directory-level fsync on files generated by compaction


Each sst file generated through compaction will perform the fsync operation of the file to ensure that the data is placed on the disk. Why do we need the fsync operation at the directory level?

I think that as long as each file has performed the fsync operation, there is no need to perform the fsync operation at the directory level. What is the purpose of this?


Solution

  • As mentioned in the man pages https://man7.org/linux/man-pages/man2/fsync.2.html

    Calling fsync() does not necessarily ensure that the entry in the
           directory containing the file has also reached disk.  For that an
           explicit fsync() on a file descriptor for the directory is also
           needed.
    

    When new files are created the directory needs to be fsync'd too