英文:
Why does rocksdb need to perform directory-level fsync on files generated by compaction
问题
每个经过合并生成的sst文件都会执行文件的fsync操作,以确保数据被写入磁盘。为什么需要在目录级别执行fsync操作呢?我认为只要每个文件都执行了fsync操作,就没有必要在目录级别执行fsync操作。这样做的目的是什么?
英文:
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?
答案1
得分: 0
如 man 页面中所述 https://man7.org/linux/man-pages/man2/fsync.2.html
调用 fsync() 并不一定确保包含文件的目录条目也已经达到磁盘。为此,还需要对目录的文件描述符执行显式 fsync()。
当创建新文件时,目录也需要进行 fsync。
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论