4 ms·
> What is the issue? What are the implications? Is there a written summary some place? The gist of the issue is that you can not retry fsync(), unless you're o
by masklinn 5y ago
> What is the issue? What are the implications? Is there a written summary some place?
The gist of the issue is that you can not retry fsync(), unless you're on freebsd.
There are no defined guarantees as to the state of the buffers on fsync() failure, most OS will just invalidate the buffers regardless. So if you retry fsync() on failure, the first call fails and discards your data, and the second trivially succeeds since there's no buffered data.
FreeBSD is the only one which keeps the buffer as-is on failure. Since this issue was uncovered, OpenBSD was also modified such that an fsync() failure would be sticky (so retrying is useless, but at least it's not misleading).
Linux had the additional issue that it would commonly fail to report errors entirely, but that is not the main problem.