Hacker News new | past | comments | ask | show | jobs | submit login

If my memory serves correctly, Session Restore doesn't use sync()/fsync() at all.

Edit Double-checked in the code: I'm right, it doesn't.

Edit If you're interested in how Session Restore improves the safety of its writes without using sync()/fsync(), the details are on my blog: https://dutherenverseauborddelatable.wordpress.com/2014/06/2...




So you're relying on the implicit write barrier many filesystems supply that ensures that the contents of a file hit the disk before a renaming of that file does. That's adequate, but I'd personally checksum the file instead of relying on corruption causing JSON to become structurally invalid.


Well, it's better when this write barrier happens (which is not true on ext4, iirc), but we rely mostly on the the fact that operating systems flush automatically within 20 seconds (I don't remember the actual numbers, but I'm almost sure it's actually within at most 5 second in practice).

Checksums/signatures would be more precise, indeed.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: