PostgreSQL used fsync incorrectly for 20 years
Doesn&#x27;t this affect all databases?  Or is it a different issue?<p><a href="https:&#x2F;&#x2F;www.sqlite.org&#x2F;atomiccommit.html" rel="nofollow">https:&#x2F;&#x2F;www.sqlite.org&#x2F;atomiccommit.html</a><p><i>SQLite does a &quot;flush&quot; or &quot;fsync&quot; operation at key points. SQLite assumes that the flush or fsync will not return until all pending write operations for the file that is being flushed have completed. We are told that the flush and fsync primitives are broken on some versions of Windows and Linux. This is unfortunate. It opens SQLite up to the possibility of database corruption following a power loss in the middle of a commit. However, there is nothing that SQLite can do to test for or remedy the situation. SQLite assumes that the operating system that it is running on works as advertised. If that is not quite the case, well then hopefully you will not lose power too often.</i><p>Also this seems related:<p><a href="https:&#x2F;&#x2F;danluu.com&#x2F;file-consistency&#x2F;" rel="nofollow">https:&#x2F;&#x2F;danluu.com&#x2F;file-consistency&#x2F;</a><p><i>That results in consistent behavior and guarantees that our operation actually modifies the file after it&#x27;s completed, as long as we assume that fsync actually flushes to disk. OS X and some versions of ext3 have an fsync that doesn&#x27;t really flush to disk. OS X requires fcntl(F_FULLFSYNC) to flush to disk, and some versions of ext3 only flush to disk if the the inode changed (which would only happen at most once a second on writes to the same file, since the inode mtime has one second granularity), as an optimization.</i><p>The linked OSDI &#x27;14 paper looks good:<p><i>We find that applications use complex update protocols to persist state, and that the correctness of these protocols is highly dependent on subtle behaviors of the underlying file system, which we term persistence properties. We develop a tool named BOB that empirically tests persistence properties, and use it to demonstrate that these properties vary widely among six popular Linux file systems.</i>