Kevin Sookocheff explains how write-ahead logging protects data in databases:
A central tenet of databases is that any committed data survives a crash or a failure. Write-ahead logging is a fundamental primitive that ensures all changes to data are first written safely to stable storage before being applied. Coupling that with some careful use of sequence numbers and we can guarantee that changes made to a database can survive system crashes.
This is a core feature in pretty much every relational database and Kevin dives into how one of the key algorithms behind it works.