Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
NoBugDie
V2EX  ›  Linux

不懂就问:什么时候需要 sync directory?

  •  
  •   NoBugDie · Dec 31, 2020 · 2401 views
    This topic created in 1969 days ago, the information mentioned may be changed or developed.

    在创建文件、重命名等需要修改目录文件的文件列表数据的操作之后,需要不需要进行 sync directory 呢?

    具体到 LevelDB 的实现,在 flush manifest 文件的时候,会进行 sync directory 操作,大致原因在注释中有提到,是为了确保 manifest 中引用的文件在文件系统中存在。

    然而在创建 WAL 文件时,并没有任何 sync directory 的操作。如此,是否会因为服务器宕机造成数据丢失呢?虽然现有的日志文件系统似乎可以通过重做日志恢复文件系统的元信息。那在非日志文件系统上,岂不是凉凉?

    LevelDB 创建 WAL 文件的代码: https://github.com/google/leveldb/blob/6721eda0b46654d3531b4a0a00c90dc659b337d6/db/db_impl.cc#L1360

    LevelDB flush manifest 文件的代码: https://github.com/google/leveldb/blob/6721eda0b46654d3531b4a0a00c90dc659b337d6/util/env_posix.cc#L306

    2 replies    2020-12-31 13:47:38 +08:00
    littlewing
        1
    littlewing  
       Dec 31, 2020 via iPhone
    会的,所以用 rocksdb 吧
    NoBugDie
        2
    NoBugDie  
    OP
       Dec 31, 2020
    @littlewing rocksdb 代码比较多,但是我也没找到相关逻辑...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2917 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 04:32 · PVG 12:32 · LAX 21:32 · JFK 00:32
    ♥ Do have faith in what you're doing.