Last Class Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications

Similar documents
Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Last Class. Today s Class. Faloutsos/Pavlo CMU /615

Lecture 21: Logging Schemes /645 Database Systems (Fall 2017) Carnegie Mellon University Prof. Andy Pavlo

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Administrivia. Last Class. Faloutsos/Pavlo CMU /615

Carnegie Mellon Univ. Dept. of Computer Science Database Applications. General Overview NOTICE: Faloutsos CMU SCS

Database Recovery. Lecture #21. Andy Pavlo Computer Science Carnegie Mellon Univ. Database Systems / Fall 2018

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #19: Logging and Recovery 1

Homework 6 (by Sivaprasad Sudhir) Solutions Due: Monday Nov 27, 11:59pm

CS122 Lecture 15 Winter Term,

Recoverability. Kathleen Durant PhD CS3200

Chapter 17: Recovery System

Failure Classification. Chapter 17: Recovery System. Recovery Algorithms. Storage Structure

Review: The ACID properties. Crash Recovery. Assumptions. Motivation. Preferred Policy: Steal/No-Force. Buffer Mgmt Plays a Key Role

ARIES (& Logging) April 2-4, 2018

Crash Recovery Review: The ACID properties

Chapter 17: Recovery System

A tomicity: All actions in the Xact happen, or none happen. D urability: If a Xact commits, its effects persist.

Chapter 16: Recovery System. Chapter 16: Recovery System

Recovery System These slides are a modified version of the slides of the book Database System Concepts (Chapter 17), 5th Ed McGraw-Hill by

Crash Recovery CMPSCI 645. Gerome Miklau. Slide content adapted from Ramakrishnan & Gehrke

Outline. Purpose of this paper. Purpose of this paper. Transaction Review. Outline. Aries: A Transaction Recovery Method

CompSci 516: Database Systems

UNIT 9 Crash Recovery. Based on: Text: Chapter 18 Skip: Section 18.7 and second half of 18.8

Atomicity: All actions in the Xact happen, or none happen. Consistency: If each Xact is consistent, and the DB starts consistent, it ends up

Chapter 14: Recovery System

ACID Properties. Transaction Management: Crash Recovery (Chap. 18), part 1. Motivation. Recovery Manager. Handling the Buffer Pool.

Crash Recovery. The ACID properties. Motivation

The transaction. Defining properties of transactions. Failures in complex systems propagate. Concurrency Control, Locking, and Recovery

Crash Recovery. Chapter 18. Sina Meraji

Advanced Database Management System (CoSc3052) Database Recovery Techniques. Purpose of Database Recovery. Types of Failure.

Transaction Management: Crash Recovery (Chap. 18), part 1

some sequential execution crash! Recovery Manager replacement MAIN MEMORY policy DISK

Concurrency Control & Recovery

Database Systems ( 資料庫系統 )

Review: The ACID properties. Crash Recovery. Assumptions. Motivation. More on Steal and Force. Handling the Buffer Pool

System Malfunctions. Implementing Atomicity and Durability. Failures: Crash. Failures: Abort. Log. Failures: Media

Recovery System These slides are a modified version of the slides of the book Database System Concepts (Chapter 17), 5th Ed

CAS CS 460/660 Introduction to Database Systems. Recovery 1.1

Log-Based Recovery Schemes

Database Recovery Techniques. DBMS, 2007, CEng553 1

1/29/2009. Outline ARIES. Discussion ACID. Goals. What is ARIES good for?

Recovery from failures

Distributed Systems

Database Management System

Introduction. Storage Failure Recovery Logging Undo Logging Redo Logging ARIES

CMU SCS CMU SCS Who: What: When: Where: Why: CMU SCS

Transactions and Recovery Study Question Solutions

Last Class Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications

CS 541 Database Systems. Recovery Managers

Introduction to Database Systems CSE 444

COURSE 4. Database Recovery 2

Recovery Techniques. The System Failure Problem. Recovery Techniques and Assumptions. Failure Types

Concurrency Control & Recovery

6.830 Lecture Recovery 10/30/2017

Aries (Lecture 6, cs262a)

Database Applications (15-415)

Problems Caused by Failures

Last time. Started on ARIES A recovery algorithm that guarantees Atomicity and Durability after a crash

Last Class Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications

6.830 Lecture Recovery 10/30/2017

DATABASE DESIGN I - 1DL300

Lecture 16: Transactions (Recovery) Wednesday, May 16, 2012

Chapter 9. Recovery. Database Systems p. 368/557

Slides Courtesy of R. Ramakrishnan and J. Gehrke 2. v Concurrent execution of queries for improved performance.

User Perspective. Module III: System Perspective. Module III: Topics Covered. Module III Overview of Storage Structures, QP, and TM

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

Transaction Management. Readings for Lectures The Usual Reminders. CSE 444: Database Internals. Recovery. System Crash 2/12/17

Database Recovery. Haengrae Cho Yeungnam University. Database recovery. Introduction to Database Systems

Transaction Management Overview. Transactions. Concurrency in a DBMS. Chapter 16

Transaction Management & Concurrency Control. CS 377: Database Systems

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

Intro to Transactions

) Intel)(TX)memory):) Transac'onal) Synchroniza'on) Extensions)(TSX))) Transac'ons)

Transaction Management Overview

CS122 Lecture 18 Winter Term, All hail the WAL-Rule!

Recovery and Logging

Motivating Example. Motivating Example. Transaction ROLLBACK. Transactions. CSE 444: Database Internals

ARIES. Handout #24. Overview

Transaction Management. Pearson Education Limited 1995, 2005

CS 377 Database Systems Transaction Processing and Recovery. Li Xiong Department of Mathematics and Computer Science Emory University

CS122 Lecture 19 Winter Term,

CSE 544 Principles of Database Management Systems. Fall 2016 Lectures Transactions: recovery

In This Lecture. Transactions and Recovery. Transactions. Transactions. Isolation and Durability. Atomicity and Consistency. Transactions Recovery

Transactions. Lecture 8. Transactions. ACID Properties. Transaction Concept. Example of Fund Transfer. Example of Fund Transfer (Cont.

Crash Consistency: FSCK and Journaling. Dongkun Shin, SKKU

File Systems: Consistency Issues

RECOVERY CHAPTER 21,23 (6/E) CHAPTER 17,19 (5/E)

CS5200 Database Management Systems Fall 2017 Derbinsky. Recovery. Lecture 15. Recovery

Architecture and Implementation of Database Systems (Summer 2018)

Last Class Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications

Database Management Systems Reliability Management

Final Review. May 9, 2017

Final Review. May 9, 2018 May 11, 2018

COURSE 1. Database Management Systems

CHAPTER 3 RECOVERY & CONCURRENCY ADVANCED DATABASE SYSTEMS. Assist. Prof. Dr. Volkan TUNALI

Database System Concepts

PART II. CS 245: Database System Principles. Notes 08: Failure Recovery. Integrity or consistency constraints. Integrity or correctness of data

Database Technology. Topic 11: Database Recovery

Introduction to Data Management. Lecture #18 (Transactions)

NOTES W2006 CPS610 DBMS II. Prof. Anastase Mastoras. Ryerson University

Announcements. Transaction. Motivating Example. Motivating Example. Transactions. CSE 444: Database Internals

Transcription:

Last Class Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Basic Timestamp Ordering Optimistic Concurrency Control Multi-Version Concurrency Control C. Faloutsos A. Pavlo Lecture#23: Crash Recovery (R&G ch. 18) Faloutsos/Pavlo 15-415/615 2 Today s Class Motivation Overview Write-Ahead Log Checkpoints Logging Schemes Recovery Protocol Shadow Paging T1 A=1 A=1 Faloutsos/Pavlo 15-415/615 3 Faloutsos/Pavlo 15-415/615 4

Motivation Motivation T1 A=1 A=2 A=1 T1 A=1 A=2 A=1 Faloutsos/Pavlo 15-415/615 4 Faloutsos/Pavlo 15-415/615 4 Motivation Crash Recovery T1 A=1 Recovery algorithms are techniques to ensure database consistency, transaction atomicity and durability despite failures. Recovery algorithms have two parts: Actions during normal txn processing to ensure that the DBMS can recover from a failure. Actions after a failure to recover the database to a state that ensures atomicity, consistency, and durability. Faloutsos/Pavlo 15-415/615 4 Faloutsos/Pavlo 15-415/615 5

Crash Recovery Crash Recovery Recovery algorithms are techniques to ensure database consistency, transaction atomicity and durability despite failures. Recovery algorithms have two parts: Actions during normal txn processing to ensure that the DBMS can recover from a failure. Actions after a failure to recover the database to a state that ensures atomicity, consistency, and durability. DBMS is divided into different components based on the underlying storage device. Need to also classify the different types of failures that the DBMS needs to handle. Faloutsos/Pavlo 15-415/615 5 Faloutsos/Pavlo 15-415/615 6 Storage Types Failure Classification Volatile Storage: Data does not persist after power is cut. Examples: DRAM, SRAM Non-volatile Storage: Data persists after losing power. Examples: HDD, SDD Stable Storage: Use multiple storage devices to approximate. A non-existent form of non-volatile storage that survives all possible failures scenarios. Faloutsos/Pavlo 15-415/615 7 Transaction Failures System Failures Storage Media Failures Faloutsos/Pavlo 15-415/615 8

Transaction Failures System Failures Logical Errors: Transaction cannot complete due to some internal error condition (e.g., integrity constraint violation). Internal State Errors: DBMS must terminate an active transaction due to an error condition (e.g., deadlock) Software Failure: Problem with the DBMS implementation (e.g., uncaught divide-by-zero exception). Hardware Failure: The computer hosting the DBMS crashes (e.g., power plug gets pulled). Fail-stop Assumption: Non-volatile storage contents are assumed to not be corrupted by system crash. Faloutsos/Pavlo 15-415/615 9 Faloutsos/Pavlo 15-415/615 10 Storage Media Failure Problem Definition Non-Repairable Hardware Failure: A head crash or similar disk failure destroys all or part of non-volatile storage. Destruction is assumed to be detectable (e.g., disk controller use checksums to detect failures). No DBMS can recover from this. Database must be restored from archived version. Primary storage location of records is on non-volatile storage, but this is much slower than volatile storage. Use volatile memory for faster access: First copy target record into memory. Perform the writes in memory. Write dirty records back to disk. Faloutsos/Pavlo 15-415/615 11 Faloutsos/Pavlo 15-415/615 12

Problem Definition Undo vs. Redo Need to ensure: The changes for any txn are durable once the DBMS has told somebody that it committed. No changes are durable if the txn aborted. Undo: The process of removing the effects of an incomplete or aborted txn. Redo: The process of re-instating the effects of a committed txn for durability. How the DBMS supports this functionality depends on how it manages the buffer pool Faloutsos/Pavlo 15-415/615 13 Faloutsos/Pavlo 15-415/615 14 Management Management A=1 A=3 B=99 C=7 Faloutsos/Pavlo 15-415/615 15 Faloutsos/Pavlo 15-415/615 15

Management Management A=1 A=3 B=99 C=7 A=1 A=3 B=99 B=88 C=7 Faloutsos/Pavlo 15-415/615 15 Faloutsos/Pavlo 15-415/615 15 Management Is T1 allowed to overwrite A even Do we force T2 s changes to T1 though T2 it hasn t be written to disk? committed? A=1 A=3 B=99 B=88 C=7 Management A=1 A=3 B=99 B=88 C=7 What happens when we need to rollback T1? A=1 A=3 B=99 B=88 C=7 Faloutsos/Pavlo 15-415/615 15 Faloutsos/Pavlo 15-415/615 15

Steal Policy Force Policy Whether the DBMS allows an uncommitted txn to overwrite the most recent committed value of an object in non-volatile storage. STEAL: Is allowed. NO-STEAL: Is not allowed. Whether the DBMS ensures that all updates made by a txn are reflected on non-volatile storage before the txn is allowed to commit: FORCE: Is enforced. NO-FORCE: Is not enforced. Force writes makes it easier to recover but results in poor runtime performance. Faloutsos/Pavlo 15-415/615 16 Faloutsos/Pavlo 15-415/615 17 NO-STEAL + FORCE NO-STEAL + FORCE A=1 A=3 B=99 C=7 Faloutsos/Pavlo 15-415/615 18 Faloutsos/Pavlo 15-415/615 18

NO-STEAL + FORCE NO-STEAL + FORCE A=1 A=3 B=99 C=7 A=1 A=3 B=99 B=88 C=7 Faloutsos/Pavlo 15-415/615 18 Faloutsos/Pavlo 15-415/615 18 NO-STEAL + FORCE NO-STEAL + FORCE NO-STEAL means that T1 changes cannot be written to disk yet. A=1 A=3 B=99 B=88 C=7 FORCE means that T2 changes must be written to disk at this point. A=1 B=99 B=88 C=7 Now it s trivial to rollback T1. A=1 B=99 B=88 C=7 A=1 B=99 B=88 C=7 Faloutsos/Pavlo 15-415/615 18 Faloutsos/Pavlo 15-415/615 18

NO-STEAL + FORCE Today s Class This approach is the easiest to implement: Never have to undo changes of an aborted txn because the changes were not written to disk. Never have to redo changes of a committed txn because all the changes are guaranteed to be written to disk at commit time. But this will be slow What if txn modifies the entire database? Overview Write-Ahead Log Checkpoints Logging Schemes Recovery Protocol Shadow Paging Faloutsos/Pavlo 15-415/615 19 Faloutsos/Pavlo 15-415/615 20 Write-Ahead Log Write-Ahead Log Protocol Record the changes made to the database in a log before the change is made. Assume that the log is on stable storage. Log contains sufficient information to perform the necessary undo and redo actions to restore the database after a crash. : STEAL + NO-FORCE All log records pertaining to an updated page are written to non-volatile storage before the page itself is allowed to be overwritten in non-volatile storage. A txn is not considered committed until all its log records have been written to stable storage. Faloutsos/Pavlo 15-415/615 21 Faloutsos/Pavlo 15-415/615 22

Write-Ahead Log Protocol Write-Ahead Log Example Write a <> record to the log for each txn to mark its starting point. Log record format: <txnid, objectid, beforevalue, aftervalue> When a txn finishes, the DBMS will: Write a <> record on the log Make sure that all log records are flushed before it returns an acknowledgement to application. T1 A=99 B=5 A=99 B=5 Non-Volatile Storage Faloutsos/Pavlo 15-415/615 23 Volatile Storage Faloutsos/Pavlo 24 Write-Ahead Log Example Write-Ahead Log Example T1 ObjectId TxnId <T1, A, 99, 88> Before Value After Value A=99 B=5 T1 ObjectId TxnId <T1, A, 99, 88> <T1, B, 5, 10> Before Value After Value A=99 B=5 A=99 A=88 B=5 Non-Volatile Storage A=99 A=88 B=10 B=5 Non-Volatile Storage Volatile Storage Faloutsos/Pavlo 24 Volatile Storage Faloutsos/Pavlo 24

Write-Ahead Log Example Write-Ahead Log Example T1 ObjectId TxnId <T1, A, 99, 88> <T1, B, 5, 10> <T1 commit> Before Value After Value A=99 B=5 T1 ObjectId TxnId <T1, A, 99, 88> <T1, B, 5, 10> <T1 commit> CRASH! Before Value After Value A=99 B=5 The result is deemed safe to return to app. A=99 A=88 B=10 B=5 Non-Volatile Storage The result is deemed safe to return to app. A=99 A=88 B=10 B=5 Non-Volatile Storage Volatile Storage Faloutsos/Pavlo 24 Volatile Storage Faloutsos/Pavlo 24 Implementation Details Deferred Updates When should we write log entries to disk? When the transaction commits. Can use group commit to batch multiple log flushes together to amortize overhead. Every time the txn executes an update? Once when the txn commits? Observation: If we prevent the DBMS from writing dirty records to disk until the txn commits, then we don t need to store their original values. <T1, A, 99, 88> <T1, B, 5, 10> <T1 commit> Faloutsos/Pavlo 15-415/615 25 Faloutsos/Pavlo 15-415/615 26

Deferred Updates Deferred Updates Observation: If we prevent the DBMS from writing dirty records to disk until the txn commits, then we don t need to store their original values. <T1, A, 99, X 88> <T1, B, X 5, 10> <T1 commit> Observation: If we prevent the DBMS from writing dirty records to disk until the txn commits, then we don t need to store their original Replay the values. log and Simply ignore all of redo each update. T1 s updates. <T1, A, 88> <T1, B, 10> <T1 commit> CRASH! <T1, A, 88> <T1, B, 10> CRASH! Faloutsos/Pavlo 15-415/615 26 Faloutsos/Pavlo 15-415/615 27 Deferred Updates Policies This won t work if the change set of a txn is larger than the amount of memory available. The DBMS cannot undo changes for an aborted txn if it doesn t have the original values in the log. We need to use the STEAL policy. NO-STEAL STEAL NO-FORCE Fastest FORCE Slowest Runtime Performance NO-STEAL STEAL NO-FORCE Slowest FORCE Fastest No Undo + No Redo Undo + Redo Recovery Performance Almost every DBMS uses NO-FORCE + STEAL Faloutsos/Pavlo 15-415/615 28 Faloutsos/Pavlo 15-415/615 29

Today s Class Checkpoints Overview Write-Ahead Log Checkpoints Logging Schemes Recovery Protocol Shadow Paging The will grow forever. After a crash, the DBMS has to replay the entire log which will take a long time. The DBMS periodically takes a checkpoint where it flushes all buffers out to disk. Faloutsos/Pavlo 15-415/615 30 Faloutsos/Pavlo 15-415/615 31 Checkpoints Checkpoints Output onto stable storage all log records currently residing in main memory. Output to the disk all modified blocks. Write a <CHECKPOINT> entry to the log and flush to stable storage. <T1, A, 1, 2> <T1 commit> <T2 begin> <T2, A, 2, 3> <T3 begin> <CHECKPOINT> <T2 commit> <T3, A, 3, 4> CRASH! Faloutsos/Pavlo 15-415/615 32 Faloutsos/Pavlo 15-415/615 33

Checkpoints Checkpoints <T1, A, 1, 2> <T1 commit> <T2 begin> <T2, A, 2, 3> <T3 begin> <CHECKPOINT> <T2 commit> <T3, A, 3, 4> CRASH! Any txn that committed before the checkpoint is ignored (T1). <T1, A, 1, 2> <T1 commit> <T2 begin> <T2, A, 2, 3> <T3 begin> <CHECKPOINT> <T2 commit> <T3, A, 3, 4> CRASH! Any txn that committed before the checkpoint is ignored (T1). T2 + T3 did not commit before the last checkpoint. Need to redo T2 because it committed after checkpoint. Need to undo T3 because it did not commit before the crash. Faloutsos/Pavlo 15-415/615 33 Faloutsos/Pavlo 15-415/615 33 Checkpoints Challenges Checkpoints Frequency We have to stall all txns when take a checkpoint to ensure a consistent snapshot. Scanning the log to find uncommitted txns can take a long time. Not obvious how often the DBMS should take a checkpoint Checkpointing too often causes the runtime performance to degrade. System spends too much time flushing buffers. But waiting a long time is just as bad: The checkpoint will be large and slow. Makes recovery time much longer. Faloutsos/Pavlo 15-415/615 34 Faloutsos/Pavlo 15-415/615 35

Today s Class Logging Schemes Overview Write-Ahead Log Checkpoints Logging Schemes Recovery Protocol Shadow Paging Physical Logging: Record the changes made to a specific location in the database. Example: Position of a record in a page. Logical Logging: Record the high-level operations executed by txns. Example: The UPDATE, DELETE, and INSERT queries invoked by a txn. Faloutsos/Pavlo 15-415/615 36 Faloutsos/Pavlo 15-415/615 37 Physical vs. Logical Logging Physiological Logging Logical logging requires less data written in each log record than physical logging. Difficult to implement recovery with logical logging if you have concurrent txns. Hard to determine which parts of the database may have been modified by a query before crash. Also takes longer to recover because you must re-execute every txn all over again. Hybrid approach where log records target a single page but do not specify data organization of the page. This is the most popular approach. Faloutsos/Pavlo 15-415/615 38 Faloutsos/Pavlo 15-415/615 39

Logging Schemes Today s Class INSERT INTO X VALUES(1,2,3); Physical <T1, Table=X, =99, Offset=4, Record=(1,2,3)> <T1, Index=X_PKEY, =45, Offset=9, Key=(1,Record1)> Logical <T1, INSERT INTO X VALUES(1,2,3) > Physiological <T1, Table=X, =99, Record=(1,2,3)> <T1, Index=X_PKEY, Index=45, Key=(1,Record1)> Overview Write-Ahead Log Checkpoints Logging Schemes Recovery Protocol Shadow Paging Faloutsos/Pavlo 15-415/615 40 Faloutsos/Pavlo 15-415/615 41 Crash Recovery Today's Class ARIES Recovery algorithms are techniques to ensure database consistency, transaction atomicity and durability despite failures. Recovery algorithms have two parts: Actions during normal txn processing to ensure that the DBMS can recover from a failure. Actions after a failure to recover the database to a state that ensures atomicity, consistency, and durability. Algorithms for Recovery and Isolation Exploiting Semantics Write-ahead Logging Repeating History during Redo Logging Changes during Undo Faloutsos/Pavlo 15-415/615 42 Faloutsos/Pavlo 15-415/615 43

ARIES ARIES Main Ideas Developed at IBM during the early 1990s. Considered the gold standard in database crash recovery. Implemented in DB2. Everybody else more or less implements a variant of it. C. Mohan IBM Fellow Faloutsos/Pavlo 15-415/615 44 Write-Ahead Logging: Any change is recorded in log on stable storage before the database change is written to disk. Repeating History During Redo: On restart, retrace actions and restore database to exact state before crash. Logging Changes During Undo: Record undo actions to log to ensure action is not repeated in the event of repeated failures. Faloutsos/Pavlo 15-415/615 46 ARIES Main Ideas ARIES Recovery Phases Write Ahead Logging Fast, during normal operation Least interference with OS (i.e., STEAL, NO FORCE) Fast (fuzzy) checkpoints On Recovery: Redo everything. Undo uncommitted txns. Analysis: Read the to identify dirty pages in the buffer pool and active txns at the time of the crash. Redo: Repeat all actions starting from an appropriate point in the log. Undo: Reverse the actions of txns that did not commit before the crash. Faloutsos/Pavlo 15-415/615 47 Faloutsos/Pavlo 15-415/615 48

ARIES - Overview Additional Crash Issues Oldest log record of txn active at crash Oldest log record in dirty page table after Analysis Start from last checkpoint found via Master Record. Three phases. Analysis - Figure out which txns committed or failed since checkpoint. What happens if system crashes during the Analysis Phase? During the Redo Phase? How do you limit the amount of work in the Redo Phase? Flush asynchronously in the background. Last checkpoint CRASH! A R U Redo all actions (repeat history) Undo effects of failed txns. How do you limit the amount of work in the Undo Phase? Avoid long-running txns. 49 Faloutsos/Pavlo 15-415/615 50 Today s Class Shadow Paging Overview Write-Ahead Log Checkpoints Logging Schemes Recovery Protocol Shadow Paging Maintain two separate copies of the database (master, shadow) Updates are only made in the shadow copy. When a txn commits, atomically switch the shadow to become the new master. : NO-STEAL + FORCE Faloutsos/Pavlo 15-415/615 51 Faloutsos/Pavlo 15-415/615 52

Shadow Paging Shadow Paging Example Database is a tree whose root is a single disk block. There are two copies of the tree, the master and shadow The root points to the master copy. Updates are applied to the shadow copy. DB Root 1 2 3 4 Master Table Non-Volatile Storage s on Portions courtesy of the great Phil Bernstein Faloutsos/Pavlo 15-415/615 53 Faloutsos/Pavlo 15-415/615 54 Shadow Paging To install the updates, overwrite the root so it points to the shadow, thereby swapping the master and shadow: Before overwriting the root, none of the transaction s updates are part of the diskresident database After overwriting the root, all of the transaction s updates are part of the diskresident database. Portions courtesy of the great Phil Bernstein Faloutsos/Pavlo 15-415/615 55 Shadow Paging Example Read-only txns access the current master. DB Root 1 2 3 4 Master Table 1 2 3 4 Shadow Table Non-Volatile Storage s on Faloutsos/Pavlo 15-415/615 56

Shadow Paging Example Read-only txns access the current master. Non-Volatile Storage Shadow Paging Example Read-only txns access the current master. Non-Volatile Storage DB Root 1 2 3 4 Master Table 1 2 3 4 Shadow Table s on DB Root 1 2 3 4 Master Table 1 2 3 4 Shadow Table s on Active modifying txn updates shadow pages. Faloutsos/Pavlo 15-415/615 56 Active modifying txn updates shadow pages. Faloutsos/Pavlo 15-415/615 56 Shadow Paging Example Read-only txns access the current master. DB Root X 1 2 3 4 Master Table 1 2 3 4 Shadow Table Active modifying txn updates shadow pages. Non-Volatile Storage s on Faloutsos/Pavlo 15-415/615 56 X X X Shadow Paging Undo/Redo Supporting rollbacks and recovery is easy. Undo: Simply remove the shadow pages. Leave the master and the DB root pointer alone. Redo: Not needed at all. Faloutsos/Pavlo 15-415/615 57

Shadow Paging Advantages Shadow Paging Disadvantages No overhead of writing log records. Recovery is trivial. Copying the entire page table is expensive: Use a page table structured like a B+tree No need to copy entire tree, only need to copy paths in the tree that lead to updated leaf nodes Commit overhead is high: Flush every updated page, page table, & root. Data gets fragmented. Need garbage collection. Faloutsos/Pavlo 15-415/615 58 Faloutsos/Pavlo 15-415/615 59 Summary Conclusion Write-Ahead Log to handle loss of volatile storage. Use incremental updates (i.e., STEAL, NO- FORCE) with checkpoints. On recovery: undo uncommitted txns + redo committed txns. Recovery is really hard. Be thankful that you don t have to write it yourself. Faloutsos/Pavlo 15-415/615 60 Faloutsos/Pavlo 15-415/615 61