[
https://issues.apache.org/jira/browse/ZOOKEEPER-2003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14086534#comment-14086534
]
Raul Gutierrez Segales commented on ZOOKEEPER-2003:
---------------------------------------------------
bq. To be safe, both the log directory, and parent directory of the log
directory should be fsynced as well.
That sounds like more than needed. We only need to fsync the parent directory
when the logfile has *just been created*, every other append doesn't need an
fsync of the parent dir (maybe you meant that, but the last statement seems to
be overreaching).
See:
http://www.quora.com/Linux/When-should-you-fsync-the-containing-directory-in-addition-to-the-file-itself
> Missing fsync() on the logs parent directory
> --------------------------------------------
>
> Key: ZOOKEEPER-2003
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2003
> Project: ZooKeeper
> Issue Type: Bug
> Affects Versions: 3.4.6
> Reporter: Samer Al-Kiswany
>
> After studying the steps ZooKeeper takes to update the logs we found the
> following bug. The bug may not manifest in the current file system
> implementations, but it violates the POSIX recommendations and may be an
> issue in some file systems.
> Looking at the strace of zookeeper we see the following:
> mkdir(v)
> create(v/log)
> append(v/log)
> trunk(v/log)
> write(v/log)
> fdatasync(v/log)
> Although the data is fdatasynced to the log, the parent directory was never
> fsynced, consequently in case of a crash, the parent directory or the log
> file may be lost, as the parent directory and file metadata were never
> persisted on disk.
> To be safe, both the log directory, and parent directory of the log directory
> should be fsynced as well.
--
This message was sent by Atlassian JIRA
(v6.2#6252)