4 ms·
One would hope that the completion of sync() would mean the data is written out, except I recently read this horror[1] on HN: Unfortunately, most consumer-grad
by deathanatos 13y ago
One would hope that the completion of sync() would mean the data is written out, except I recently read this horror[1] on HN:
Unfortunately, most consumer-grade mass storage devices lie about syncing. Disk drives will report that content is safely on persistent media as soon as it reaches the track buffer and before actually being written to oxide. This makes the disk drives seem to operate faster (which is vitally important to the manufacturer so that they can show good benchmark numbers in trade magazines). And in fairness, the lie normally causes no harm, as long as there is no power loss or hard reset prior to the track buffer actually being written to oxide. But if a power loss or hard reset does occur, and if that results in content that was written after a sync reaching oxide while content written before the sync is still in a track buffer, then database corruption can occur.
… part of me hopes there's a very special hell for the people making disks where the OS can never be sure if the data is safe or not.
[1]: http://www.sqlite.org/howtocorrupt.html http://www.sqlite.org/howtocorrupt.html
- mark-r 13y agoDoes anybody know if SSD is subject to the same delayed sync issue?
- masklinn 13y agoAs with regular drives, it depends on the device. Early Intel SSDs were known to be particularly prone to this issue: http://www.mysqlperformanceblog.com/2009/03/02/ssd-xfs-lvm-fsync-write-cache-barrier-and-lost-transactions/ http://www.mysqlperformanceblog.com/2009/03/02/ssd-xfs-lvm-f... http://www.evanjones.ca/intel-ssd-durability.html http://www.evanjones.ca/intel-ssd-durability.html
- magila 13y agoThis problem is nowhere near as widespread as most people claim. While bugs do happen and I can't speak for the SSD side of things, HDD manufactures test their cache behavior quite thoroughly. This includes pulling the power immediately after flushing the cache to make sure the data made it to disk. 99% of people who report cases of HDDs "lying" about write integrity either have write cache enabled or are not actually issuing a flush cache command due to OS level issues.