concept Data & storage
WAL commit durability and crash recovery
A changed page can still be unwritten when a transaction commits. What matters for crash recovery is whether the durable log records both the change and its commit—not just whether the client received a reply.
What it means
Write-ahead logging (WAL) lets a database recover a committed change after a crash even if the changed data page never reached durable storage. The log records what changed and, in a later record, that the transaction committed. If both records survive, recovery can use the log to redo the change on the older page. The database need not flush every changed page at commit.
Here, durable means the write has reached storage that will retain it through the crash being considered. A commit acknowledgment tells you what the client heard. It does not mean every page was written, and whether it establishes that the commit record was durable depends on what the database promised before replying.
Try it
Simulation: consider one transaction at the instant of a crash. In the starting example, both WAL records are durable, the changed page is not, and the client has received an acknowledgment. The result is recover: the log contains both the change needed for redo and the record of its commit.
WAL commit durability and crash recovery
Show commit log flush boundaries and what a crash can recover
Durable committed WAL can support redo, even if changed page was not flushed.
Write-ahead conditions
- Change recordyes
- Log flushyes
- Data page persistedNot evaluated
- Client acknowledgmentyes
After modeled crash
- Durable commitEstablished in model
These flags are premises, not observed disk writes. A successful response is not a durability guarantee. Recovery verdict covers only the modeled logged change.
Evaluated inputs
- Required scenario evidence
- provided
- Change WAL record durable
- yes
- Commit WAL record durable
- yes
- Client acknowledgment
- yes
Not evaluated: Changed data page durable
One change WAL record and later commit record; durable page may precede commit if change WAL already durable. Reliable storage assumed, no engine-specific recovery algorithm or actual settings changes.
About this model
The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.
Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.
- Change
Commit WAL record durabletono. LeaveClient acknowledgmentatyes. The result becomesnot-guaranteed. The change record still describes the edit, but the durable log no longer establishes that the transaction committed. - Now set
Changed data page durabletoyes. The result staysnot-guaranteed. The page can reach storage after the change record but before the commit record. Finding the edit on the page is not proof of commit. - With that page still durable, set
Change WAL record durabletono. The result isinvalid-order: the page would have reached storage without its required log record. This is a contradiction in the example, not a prediction about recovery.
Set Required scenario evidence to missing to see a different limit: the outcome is unknown, even if the other selections look sufficient. Reset restores the starting example. These are local, synthetic choices; they do not inspect or change a database.
Which write has to come first?
The “ahead” in write-ahead logging refers to the change record: it must be durable before the corresponding data-page change is written to storage. It does not mean that the page must wait for commit. Once the change record is durable, the page can lag behind the commit record, as in the starting example, or reach storage before it, as in step 2. That is why page persistence does not decide between those two outcomes. The difference is how far the durable log extends at the crash: through the change, or through its commit as well.
The reply to the client answers a separate question. With PostgreSQL asynchronous commit, the client can receive success before the commit record is flushed. A crash in that interval can lose a recently acknowledged transaction while still leaving the recovered database consistent. not-guaranteed describes the missing assurance; it is not a finding that a particular transaction was lost.
The converse of an acknowledged but unflushed commit matters too. Keep both log records durable and set the acknowledgment to no. The model still reports recovery, even though the client did not receive success. From the client alone, however, an uncertain response cannot establish either commit or rollback. The contradictory invalid-order case is not a recovery verdict at all.
In practice
If an application log says “commit succeeded,” start by recording just that observation. Check what the applicable commit setting required before success could be returned, what is known about the durable WAL position at the crash, and whether the operating system and storage device honored synchronization requests. If the last durable position is unknown, do not substitute the acknowledgment or a stored page for that missing evidence.
Restoring from a backup adds another requirement: the log needs a usable starting point. For example, the PostgreSQL 18.7 release notes warn that earlier incremental backups may be corrupt and recommend a new full backup after updating as the basis for future incremental backups. A durable commit record cannot validate that backup chain; verify a restore before relying on it.
For crash recovery, ask whether the log reached the transaction’s commit record on storage you can trust, not whether the client saw success or the latest page made it to disk. Those observations answer different questions.
Frequently asked questions
Editorial questions, answered from the sources listed for this article.
Can WAL be durable before data page?
Yes. The relevant WAL must be durable before corresponding data-file changes are written. Redo can then reconstruct changes after a crash without requiring every modified data page to be flushed at commit.
Does asynchronous commit weaken durability?
It can allow loss of recent acknowledged transactions after crash.
Does fsync solve failing hardware?
No. Synchronization relies on the operating system and storage honoring durability guarantees. A successful call does not prove that a failing device will preserve or return the data.
Is WAL a backup?
Not by itself. WAL needs an appropriate starting database state. Establish a usable base backup and required log history, then verify the restore procedure. PostgreSQL 18.7 also documents a correction affecting earlier incremental backups; one durable commit record cannot validate the backup chain.
Sources & model boundaries
Primary references used for this explanation. The interactive example is an educational model, not a live check.
- PostgreSQL 18: Write-Ahead Logging (WAL)
§28.3. WAL records describing changes must be flushed to durable storage before corresponding data-file changes are written. Redo can recover from crash without flushing every changed data page at transaction commit. WAL archiving supports point-in-time recovery with a suitable base backup.
Checked .
- PostgreSQL reliability
Reliability. Durability depends on OS and device caches and reliable synchronization to nonvolatile storage.
Checked .
- PostgreSQL 18: asynchronous commit
28.4. A crash can lose recently committed transactions whose WAL was not flushed, while recovery returns a consistent state.
Checked .
- PostgreSQL backup and restore
25 backup and restore. Database backup approaches include dumps, filesystem backup and continuous archiving, with distinct tradeoffs.
Checked .
- PostgreSQL 18.7 release notes
E.1.1 Migration to Version 18.7; incremental backup changes. Warns of potential corruption of prior incremental backups; new full backup after update provides the basis for future incremental backups.
Checked .