Durable File Replacement

Turkish equivalent: Dayanıklı dosya değiştirmeDomain: Storage Systems

A write pattern that combines atomic visibility with file and directory synchronization so replacement survives a crash under the intended storage contract.

Writing a temporary file and replacing the target with rename() can provide atomic visibility to readers, but that alone does not prove the new directory entry will survive a power loss or kernel crash.

For a local file system, a typical durability sequence is:

temporary file write
-> fsync(file)
-> rename(temp, target)
-> fsync(parent directory)

Each step protects a different boundary. fsync concerns persisted file data and metadata, Atomic Rename concerns namespace visibility, and Directory fsync concerns persistence of the directory entry. With network storage, NFS Close-to-Open Consistency adds another visibility contract.

The end-to-end failure model is discussed in Atomic Publication in File Processing.