# Shadow paging

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Shadow_paging
> Markdown URL: https://mediated.wiki/source/Shadow_paging.md
> Source: https://en.wikipedia.org/wiki/Shadow_paging
> Source revision: 1352278116
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{No footnotes|date=January 2014}}

In [computer science](/source/computer_science), '''shadow paging''' is a technique for providing [atomicity](/source/Atomic_(computer_science)) and [durability](/source/Durability_(computer_science)) (two of the [ACID](/source/ACID) properties) in [database system](/source/database_system)s. A ''page'' in this context refers to a unit of physical storage (probably on a [hard disk](/source/hard_disk)), typically of the order of 1 to 64 [KiB](/source/KiB).

Shadow paging is a [copy-on-write](/source/copy-on-write) technique for avoiding [in-place](/source/in-place) updates of pages. Instead, when a page is to be modified, a ''shadow page'' is allocated. Since the shadow page has no references (from other pages on disk), it can be modified without concern for consistency constraints, etc. When the page is ready to become durable, all pages that referred to the original are updated to refer to the new replacement page instead. Since the page is "activated" only when it is ready, it is [atomic](/source/Atomic_(computer_science)).

If the referring pages must also be updated via shadow paging, this procedure may [recurse](/source/recursion) many times, becoming costly. One solution, employed by the [Write Anywhere File Layout](/source/Write_Anywhere_File_Layout) (WAFL) file system, is to be lazy about making pages durable (i.e., write-behind caching). This increases performance significantly by avoiding many writes on hotspots high in the referential hierarchy (e.g., a file system superblock) at the cost of high commit latency.<ref>{{cite journal |title=File System Design for an NFS File Server Appliance |date=1994 |url=https://www.cs.princeton.edu/courses/archive/fall09/cos318/reading/netapp.pdf |accessdate=1 November 2019}}</ref>

[Write-ahead logging](/source/Write-ahead_logging) is a more popular solution that uses in-place updates.{{fact|date=September 2012}}

Shadow paging is similar to the '''old master&ndash;new master''' batch processing technique used in mainframe database systems. In these systems, the output of each batch run (possibly a day's work) was written to two separate [disks](/source/Hard_disk) or other form of storage medium. One was kept for backup, and the other was used as the starting point for the next day's work.

Shadow paging is also similar to [purely functional data structure](/source/purely_functional_data_structure)s, in that in-place updates are avoided.

==References==
{{Reflist}}

Category:Database algorithms
Category:Computer file systems

---
Adapted from the Wikipedia article [Shadow paging](https://en.wikipedia.org/wiki/Shadow_paging) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Shadow_paging?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
