为什么RocksDB需要对由压实生成的文件执行目录级别的fsync

huangapple go评论87阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年4月17日 12:34:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76031740.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定