Durability in ACID Transactions
Durability, the D in ACID, is the guarantee that once a transaction commits, its changes are permanent, even if the database crashes, the server loses power or the system restarts immediately afterward. Databases achieve it by flushing the transaction's write-ahead log entry to durable storage before acknowledging the commit, then replaying the log on restart.
Durability, the "D" in ACID, is the guarantee that once a transaction has committed, its changes are permanent. Even if the database process crashes, the server loses power, or the operating system restarts a millisecond after the commit was acknowledged, that committed data must still be there when the system comes back up.
Why this is a real engineering problem
A commit needs to feel instantaneous to the application waiting on it, but writing data all the way to a physical disk is comparatively slow. Databases solve this tension the same way they solve atomicity: with a write-ahead log. Before a commit is acknowledged as successful, the database ensures the log entry describing that transaction's changes has been physically written (flushed) to durable storage, not just held in memory or an OS-level buffer that could be lost on a crash.
Once that log entry is safely on disk, the transaction is durable, even if the actual database files haven't been updated with the final result yet, the database can always replay the log on restart to reconstruct the committed changes.
How it plays out during a crash
- A transaction commits. The database flushes its write-ahead log entry to disk and acknowledges the commit to the application.
- The system crashes immediately after, before the actual data files have been updated to reflect the change.
- On restart, the database reads its write-ahead log from disk.
- It finds the log entry for the committed transaction and replays it, applying the change to the actual data files.
- The data is now consistent with what was committed, exactly as if the crash never interrupted anything.
A worked example
An order-processing system commits a transaction marking order_id = 4821 as paid, and the confirmation email trigger fires based on that commit. A split second later, the server loses power entirely.
Without durability, that commit might only have existed in memory, and the power loss would erase it, the order would come back up as unpaid even though the customer's payment succeeded and a confirmation was sent. With durability, the write-ahead log entry for that commit was already flushed to disk before the commit was acknowledged, so when the server reboots and the database restarts, it replays that log entry and the order is correctly marked paid, matching the confirmation email that already went out.
Where this matters in real systems
Durability is why database administrators care deeply about disk write guarantees, whether a storage system genuinely flushes data to physical media when asked, or lies and reports success while the data still sits in a volatile cache. Cloud database services like Amazon RDS and managed PostgreSQL offerings are explicit about which storage tier and replication setup they use specifically because durability guarantees are only as strong as the underlying disk's honesty about what's actually been written.
What interviewers actually ask about durability
- "What does durability guarantee?" That once a transaction commits, its changes survive permanently, even through an immediate crash or power loss.
- "How is durability implemented?" Through a write-ahead log that gets physically flushed to durable storage before a commit is acknowledged, so it can be replayed on restart if needed.
- "How is durability different from atomicity?" Atomicity is about a transaction completing entirely or not at all; durability is about what happens to a transaction's result after it has already committed, ensuring that result is never lost.
- "Why can't a database just keep committed data in memory for speed?" Memory doesn't survive a crash or power loss; durability specifically requires the commit to be safe against exactly that kind of failure, which memory alone can't provide.
Key takeaways
- Durability guarantees a committed transaction's changes are permanent, surviving crashes and power loss.
- It's implemented through a write-ahead log flushed to durable storage before a commit is acknowledged.
- On restart after a crash, the database replays its log to restore any committed changes not yet reflected in the main data files.
- Durability only holds as strongly as the underlying storage's real write guarantees, which is why storage choice matters for systems that depend on it.
More in ACID Properties
Browse all DBMS topics
Log in to save which topics you've read across every subject.
Frequently asked questions
What does durability guarantee?
That once a transaction commits, its changes survive permanently, even through an immediate crash or power loss.
How is durability implemented?
Through a write-ahead log that gets physically flushed to durable storage before a commit is acknowledged, so it can be replayed on restart if needed.
How is durability different from atomicity?
Atomicity is about a transaction completing entirely or not at all; durability is about what happens to a transaction's result after it has already committed, ensuring that result is never lost.
Why can't a database just keep committed data in memory for speed?
Memory doesn't survive a crash or power loss; durability specifically requires the commit to be safe against exactly that kind of failure, which memory alone can't provide.