
On Tue, 10 Apr 2012, Toby Corkindale wrote:
On 10/04/12 16:44, Tim Connors wrote:
(if you can't tell, I have a pet hate for people that insist fsync() is the only true way to ensure data integrity. Use a reliable filesystem instead!)
Soooo.... if you aren't using fsync(), then what happens if you write() to a file, say your database of orders, then write to the HTTP socket to tell the user their order went through, and then you have a power failure ten seconds later, before the operating system has got around to flushing that data to disk?
Sure. You're doing transactions. Do transactions properly. Probably outside of a filesystem alltogether - put your database on a raw block device. What if my desktop or mozilla have just updated a config file and then the power fails? Should I have to wait 40 seconds in which the entire system activity freezes, and I have no gaurantee which version I get, or should I have to wait no time at all and have no guarantee which version I get? As long as it is atomically renamed either way, I'll happily go with the version that doesn't unnecessarily spin up my spundown disks, and doesn't cause me to wait for something unimportant to happen. -- Tim Connors