01 · Why it’s true
When a program calls write(), the kernel usually copies the data into the page cache in memory and returns right away. The data reaches the disk later, in the background.
That makes writes fast, but it means a successful write doesn’t mean the data is on disk. A crash or power loss can lose recent writes unless the program calls fsync(), which waits until the storage device confirms. Databases call fsync on commit for exactly this reason — which is why commit latency depends on storage latency.
02 · Picture it
03 · In the interview
- Explaining what a database commit actually guarantees, and what it costs.
- Diagnosing slow disks:
iostatlatency and utilization, and I/O wait. - Explaining why the second read of a file is faster than the first.
04 · Practice question
“After a power loss, an application lost its last few seconds of data, even though every write returned success. Why?”
A strong answer covers
- A successful
write()usually means the data reached the page cache, not the disk. - Without
fsync()(or equivalent options), dirty pages are flushed later, so a crash can lose them. - Check whether the app or its database syncs on commit, and whether the storage has a volatile write cache.
- Trade-off: syncing every write adds latency, so batch or group commits where it’s safe.