Datadurable writefsync

Durability

Definition

Durability means an acknowledged write is not lost: the system makes the change persistent, on disk or on other machines, before telling the client it succeeded.

In practice

A single database achieves it by flushing the write-ahead log with fsync before acknowledging a commit, then replaying the log after a crash. Losing the machine or its disk still loses data, so systems extend durability with synchronous replication to a standby or with replicated logs, where the acknowledgement waits for another node.

Durability costs latency on every write, which tempts teams to relax it: synchronous_commit = off, write-behind caches and asynchronous replicas all acknowledge before the data is safe. That can be a fair trade for metrics or click logs, but it means a crash silently loses writes the client was told had succeeded.

Example

With synchronous_commit = on a commit waits about 1 ms for the WAL flush; with it off, commits return immediately but up to roughly 600 ms of acknowledged transactions can vanish in a crash.