Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Write-ahead logging
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Family of computer science techniques}} {{More citations needed|date=June 2022}} In [[computer science]], '''write-ahead logging''' ('''WAL''') is a family of techniques for providing [[Atomicity (database systems)|atomicity]] and [[Durability (database systems)|durability]] (two of the [[ACID]] properties) in [[database system]]s.<ref name="Hellerstein Stonebraker Hamilton p. ">{{cite book | last1=Hellerstein | first1=Joseph M. | last2=Stonebraker | first2=Michael | last3=Hamilton | first3=James | title=Architecture of a database system | publisher=Now | publication-place=Boston | date=2007 | isbn=978-1-60198-079-3 | oclc=191079239 | page=}}</ref> A write ahead log is an append-only auxiliary disk-resident structure used for crash and transaction recovery. The changes are first recorded in the log, which must be written to [[stable storage]], before the changes are written to the database.<ref>{{Cite web |date=2023-05-11 |title=30.3. Write-Ahead Logging (WAL) |url=https://www.postgresql.org/docs/15/wal-intro.html |access-date=2023-06-05 |website=PostgreSQL Documentation |language=en}}</ref> The main functionality of a write-ahead log can be summarized as:<ref>{{Cite book |author=Petrov, Alex |url=http://worldcat.org/oclc/1103591515 |title=Database Internals : a deep dive into how distributed data systems work |date=2019 |publisher=O'Reilly Media |isbn=978-1492040347 |oclc=1103591515}}</ref> * Allow the page cache to buffer updates to disk-resident pages while ensuring durability semantics in the larger context of a database system. * Persist all operations on disk until the cached copies of pages affected by these operations are synchronized on disk. Every operation that modifies the database state has to be logged on disk before the contents on the associated pages can be modified * Allow lost in-memory changes to be reconstructed from the operation log in case of a crash. In a system using WAL, all modifications are written to a [[Database log|log]] before they are applied. Usually both redo and undo information is stored in the log. The purpose of this can be illustrated by an example. Imagine a program that is in the middle of performing some operation when the machine it is running on loses power. Upon restart, that program might need to know whether the operation it was performing succeeded, succeeded partially, or failed. If a write-ahead log is used, the program can check this log and compare what it was supposed to be doing when it unexpectedly lost power to what was actually done. On the basis of this comparison, the program could decide to undo what it had started, complete what it had started, or keep things as they are. After a certain amount of operations, the program should perform a [[Application checkpointing|checkpoint]], writing all the changes specified in the WAL to the database and clearing the log. WAL allows updates of a database to be done [[in-place algorithm|in-place]]. Another way to implement atomic updates is with [[shadow paging]], which is not in-place. The main advantage of doing updates in-place is that it reduces the need to modify indexes and block lists. [[Algorithms for Recovery and Isolation Exploiting Semantics|ARIES]] is a popular algorithm in the WAL family. Modern [[file system]]s typically use a variant of WAL for at least file system [[metadata]]; this is called [[Journaling file system|journaling]]. ==References== {{Reflist}} [[Category:Database algorithms]] {{database-stub}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Database-stub
(
edit
)
Template:More citations needed
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)