Durability

Committed data is saved permanently

“Durability ensures that once a transaction has been committed, it will remain so even in the event of power loss, crashes, or errors.”

When to use

Always for persistent data.

Why it matters

  • Trust: Users trust that if the screen said “Saved”, it is actually saved.

Signs of Violation

  • Data loss after a power outage.
  • Writing only to memory (Redis without persistence) and claiming it’s saved.

Explanation

Problem

Memory (RAM) is volatile. Disks are slow.

Solution

Write Ahead Logs (WAL). Data is written to disk before the transaction is acknowledged as “Success”.

Real world analogy

A receipt. Once the store gives you a receipt, the transaction is durable. Even if the cashier forgets, you have proof (Disk record) that it happened.

Pros and Cons

Pros Cons
  • Data Safety
  • Disk I/O latency
  • Comparison

    • fsync: The system call that forces the OS to flush buffers to the physical disk.

    Code example

    Typescript

    Bad (Violation)

    Good (Adherence)

    PHP

    Good (Adherence)