Skip to content
hashkey.bond

Archivestorage

When fsync Lies

Disks with volatile write caches, filesystems that ignore flushes, and virtualization layers that swallow them.

Published
Reading time
1 min read

fsync is supposed to flush file data to stable storage. In practice, several layers can return success without the data being durable.

The suspects

  • Drive write cache: the disk acknowledges before the platter or NAND is programmed. Enterprise drives with power-loss protection are the fix; consumer drives often are not.
  • Virtualized storage: hypervisors and cloud volumes may buffer writes and acknowledge early unless explicitly configured for durability.
  • Filesystems: some network filesystems treat flush as advisory; bugs in flush handling have shipped in production kernels.
  • Application bugs: fsync on the wrong file descriptor, or on the file but not the directory entry.

How to test

Power-cycle a test machine (not a graceful reboot) after acknowledging a write, then verify. Repeat with the filesystem and device cache configurations you plan to run. This is the only test that counts.

Takeaway: durability is a property of the whole stack, not a syscall. Test with real power loss and assume nothing about the layer below.