Database Applications (15-415) DBMS Internals- Part XIV Lecture 23, November 20, 2016 Mohammad Hammoud.

Slides:



Advertisements
Similar presentations
1 CS411 Database Systems 12: Recovery obama and eric schmidt sysadmin song
Advertisements

Crash Recovery R&G - Chapter 20
Crash Recovery John Ortiz. Lecture 22Crash Recovery2 Review: The ACID properties  Atomicity: All actions in the transaction happen, or none happens 
Transaction Management: Crash Recovery, part 2 CS634 Class 21, Apr 23, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
CS 440 Database Management Systems Lecture 10: Transaction Management - Recovery 1.
1 Crash Recovery Chapter Review: The ACID properties  A  A tomicity: All actions of the Xact happen, or none happen.  C  C onsistency: If each.
Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke 1 Crash Recovery Chapter 18.
Crash Recovery R&G - Chapter 18.
ARIES: Logging and Recovery Slides derived from Joe Hellerstein; Updated by A. Fekete If you are going to be in the logging business, one of the things.
Crash Recovery, Part 1 If you are going to be in the logging business, one of the things that you have to do is to learn about heavy equipment. Robert.
5/13/20151 PSU’s CS …. Recovery - Review (only for DB with updates…..!)  ACID: Atomicity & Durability  Trading execution time for recovery time.
1 Crash Recovery Chapter Review: The ACID properties  A  A tomicity: All actions of the Xact happen, or none happen.  C  C onsistency: If each.
Introduction to Database Systems1 Logging and Recovery CC Lecture 2.
1 Crash Recovery Chapter Review: The ACID properties  A  A tomicity: All actions in the Xact happen, or none happen.  C  C onsistency: If each.
COMP9315: Database System Implementation 1 Crash Recovery Chapter 18 (3 rd Edition)
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke 1 Crash Recovery Chapter 20 If you are going to be in the logging business, one.
Transaction Management: Crash Recovery CS634 Class 20, Apr 16, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
ICS 421 Spring 2010 Transactions & Recovery Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 3/4/20101Lipyeow.
Crash Recovery Lecture 24 R&G - Chapter 18 If you are going to be in the logging business, one of the things that you have to do is to learn about heavy.
Crash Recovery CS 186 Spring 2006, Lecture 26 & 27 R&G - Chapter 18 If you are going to be in the logging business, one of the things that you have to.
Database Management Systems 1 Logging and Recovery If you are going to be in the logging business, one of the things that you have to do is to learn about.
1 Crash Recovery Yanlei Diao UMass Amherst April 3 and 5, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Recovery with Aries. Locking Lock and Unlock take DB resources as arguments: DB, a relation, tuple, etc. Lock and Unlock take DB resources as arguments:
CPSC 461. Goal Goal of this lecture is to study Crash Recovery which is subpart of transaction management in DBMS. Crash recovery in DBMS is achieved.
Optimistic Concurrency Control & ARIES: Database Logging and Recovery Zachary G. Ives University of Pennsylvania CIS 650 – Implementing Data Management.
DatabaseSystems/COMP4910/Spring03/Melikyan1 Crash Recovery.
DURABILITY OF TRANSACTIONS AND CRASH RECOVERY These are mostly the slides of your textbook !
Logging and Recovery Chapter 18 If you are going to be in the logging business, one of the things that you have to do is to learn about heavy equipment.
1 Crash Recovery Lecture 23 Ramakrishnan - Chapter 20 If you are going to be in the logging business, one of the things that you have to do is to learn.
ARIES: Database Logging and Recovery Zachary G. Ives University of Pennsylvania CIS 650 – Implementing Data Management Systems February 9, 2005 Some content.
ARIES, Concluded and Distributed Databases: R* Zachary G. Ives University of Pennsylvania CIS 650 – Implementing Data Management Systems October 2, 2008.
© Dennis Shasha, Philippe Bonnet 2001 Log Tuning.
Implementation of Database Systems, Jarek Gryz 1 Crash Recovery Chapter 18.
1 Logging and Recovery. 2 Review: The ACID properties v A v A tomicity: All actions in the Xact happen, or none happen. v C v C onsistency: If each Xact.
Database Applications (15-415) DBMS Internals- Part XIV Lecture 25, April 17, 2016 Mohammad Hammoud.
1 Database Systems ( 資料庫系統 ) January 3, 2005 Chapter 18 By Hao-hua Chu ( 朱浩華 )
© Dennis Shasha, Philippe Bonnet 2001 Log Tuning.
Database Recovery Techniques
DURABILITY OF TRANSACTIONS AND CRASH RECOVERY
CS 440 Database Management Systems
Crash Recovery The slides for this text are organized into chapters. This lecture covers Chapter 20. Chapter 1: Introduction to Database Systems Chapter.
Crash Recovery R&G - Chapter 20
Database System Implementation CSE 507
Database Applications (15-415) DBMS Internals- Part XIII Lecture 22, November 15, 2016 Mohammad Hammoud.
Slides derived from Joe Hellerstein; Updated by A. Fekete
CS186 Slides by Joe Hellerstein Enhanced by Alan Fekete
Crash Recovery Chapter 18
Ali Ghodsi and Ion Stoica,
Database Systems (資料庫系統)
Crash Recovery R&G - Chapter 20
Crash Recovery Chapter 18
Crash Recovery The slides for this text are organized into chapters. This lecture covers Chapter 20. Chapter 1: Introduction to Database Systems Chapter.
CSIS 7102 Spring 2004 Lecture 10: ARIES
Introduction to Database Systems
Recovery I: The Log and Write-Ahead Logging
Recovery II: Surviving Aborts and System Crashes
Crash Recovery Chapter 18
CS 632 Lecture 6 Recovery Principles of Transaction-Oriented Database Recovery Theo Haerder, Andreas Reuter, 1983 ARIES: A Transaction Recovery Method.
Lecture 15 – ARIES Recovery
Kathleen Durant PhD CS 3200 Lecture 11
Crash Recovery, Part 2 R&G - Chapter 18
Crash Recovery The slides for this text are organized into chapters. This lecture covers Chapter 20. Chapter 1: Introduction to Database Systems Chapter.
Database Applications (15-415) DBMS Internals- Part XIII Lecture 25, April 15, 2018 Mohammad Hammoud.
RECOVERY MANAGER E0 261 Jayant Haritsa Computer Science and Automation
Database Recovery 1 Purpose of Database Recovery
Crash Recovery Chapter 18
Database Applications (15-415) DBMS Internals- Part XIII Lecture 24, April 14, 2016 Mohammad Hammoud.
Slides derived from Joe Hellerstein; Updated by A. Fekete
Crash Recovery Chapter 18
Presentation transcript:

Database Applications (15-415) DBMS Internals- Part XIV Lecture 23, November 20, 2016 Mohammad Hammoud

Today… Last Session: Recovery Management Today’s Session: Recovery Management (Cont’d) Announcements: P3 grades are out PS4 is due today by midnight PS5 will be posted on Tuesday. It is due on Thursday, Dec 1st

DBMS Layers Queries Query Optimization and Execution Relational Operators Transaction Manager Files and Access Methods Recovery Manager Buffer Management Lock Manager Disk Space Management Continue… DB

Outline The Log Checkpointing The ARIES Algorithm A Simple Transaction Abort Checkpointing The ARIES Algorithm

A Simple Transaction Abort For now, let us consider an “explicit” abort of a transaction T That is, no system crash is involved We want to “play back” the log in reverse order, undoing T’s updates Step 1: We get the lastLSN of T from the Transaction table Step 2: We lock the corresponding data to be undone (we can use strict 2PL) Before starting UNDO, we write an abort log record This is for recovering from a potential crash during UNDO!

A Simple Transaction Abort (Cont’d) Step 3: before restoring an old value of a page, we write a respective Compensation Log Record (CLR) CLR has one extra field, that is, undoNextLSN, which points to the next LSN to undo That is, the prevLSN of the record we are currently undoing CLRs are never undone (but they might be Redone) Step 4: repeat steps 2 and 3 by following a chain of log records backward via the prevLSN field Last Step: at the end of UNDO, write an end log record

Let us assume T1000 is aborted! An Example PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 Let us assume T1000 is aborted! prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 LOG Transaction Table

Step 1: Get the lastLSN of T1000 from the Transaction table An Example PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 Step 1: Get the lastLSN of T1000 from the Transaction table prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 LOG Transaction Table

An Example Step 2: Lock P505 P500 P600 P505 P500 P600 P505 P500 P600 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 Step 2: Lock P505 prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 LOG Transaction Table

An Example Step 3: Write CLR P500 P600 P505 P500 P600 P505 P500 P600 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 Step 3: Write CLR prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 LOG Transaction Table

An Example Step 3: Write CLR P500 P600 P505 P500 P600 P505 P500 P600 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 Step 3: Write CLR prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 LOG Transaction Table

Step 4: Restore old value “TUV” An Example PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 Step 4: Restore old value “TUV” prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 LOG Transaction Table

Step 4: Restore old value “TUV” An Example PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 PageID recLSN P500 P600 P505 Step 4: Restore old value “TUV” prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 LOG Transaction Table

Step 4: Restore old value “TUV” An Example PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 Step 4: Restore old value “TUV” prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 LOG Transaction Table

An Example Step 5: Lock P500 P500 P600 P500 P600 P500 P600 P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 Step 5: Lock P500 prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 LOG Transaction Table

An Example Step 6: Write CLR P500 P600 P500 P600 P500 P600 P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 Step 6: Write CLR prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Undo T1000- LSN 10 Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 Transaction Table LOG

Step 7: Restore old value “ABC” An Example PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 Step 7: Restore old value “ABC” prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Undo T1000- LSN 10 Dirty Page Table TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 TransID lastLSN T1000 T2000 Transaction Table LOG

Step 7: Restore old value “ABC” An Example PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 Step 7: Restore old value “ABC” prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Undo T1000- LSN 10 Dirty Page Table TransID lastLSN T1000 TransID lastLSN T1000 TransID lastLSN T2000 Transaction Table LOG

Step 7: Restore old value “ABC” An Example PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 Step 7: Restore old value “ABC” prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Undo T1000- LSN 10 Dirty Page Table TransID lastLSN T1000 TransID lastLSN T1000 TransID lastLSN T2000 Transaction Table LOG

Step 8: Write an end log record An Example PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 Step 8: Write an end log record prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Undo T1000- LSN 10 Dirty Page Table TransID lastLSN T1000 TransID lastLSN T1000 TransID lastLSN T2000 Transaction Table LOG

Step 8: Write an end log record An Example PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 PageID recLSN P500 P600 Step 8: Write an end log record prevLSN transID Type pageID Length Offset Before-Image After-Image 10 T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS 50 P505 TUV WXY Undo T1000- LSN 50 CLR Undo T1000- LSN 10 T1000 End- LSN 10 END prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY prevLSN transID Type pageID Length Offset Before-Image After-Image T1000 Update P500 3 21 ABC DEF T2000 P600 41 HIJ KLM 20 GDE QRS P505 TUV WXY Dirty Page Table TransID lastLSN T1000 TransID lastLSN T2000 TransID lastLSN T1000 Transaction Table

Outline The Log Checkpointing The ARIES Algorithm A Simple Transaction Abort Checkpointing The ARIES Algorithm

Checkpointing To reduce the amount of work to do during recovery, DBMSs typically take checkpoints A checkpoint is like a snapshot of a DBMS state A checkpoint can be taken by writing to the log: A begin_checkpoint record This indicates the start of the checkpoint An end_checkpoint record This indicates the end of the checkpoint It includes the contents of the Transaction and the Dirty Page tables A master record This contains the LSN of the begin_checkpoint record

Outline The Log Checkpointing The ARIES Algorithm A Simple Transaction Abort Checkpointing The ARIES Algorithm

Recovering From a System Crash: ARIES We will study the ARIES algorithm for recovering from system crashes ARIES is designed to work with a steal, no-force approach When the recovery manager is invoked after a crash, restart proceeds in three phases: Analysis Redo Undo

Recovering From a System Crash: ARIES The Analysis Phase: Identifies dirty pages in the buffer pool and active transactions at the time of the crash The Redo Phase: Redoes all actions The Undo Phase: Undoes the actions of transactions that were active and did not commit Oldest log rec. of Xact active at crash Undo Smallest recLSN in dirty page table after Analysis Redo Analysis Last chkpt CRASH

ARIES: The Analysis Phase The Analysis phase encompasses two main steps: Step 1: Reconstruct state (i.e., Dirty Page and Transaction tables) via the end_checkpoint record, after the most recent begin_checkpoint record Step 2: Scan the log in the forward direction, starting after the checkpoint If an end log record is encountered Remove the corresponding transaction from the Transaction table

ARIES: The Analysis Phase The Analysis phase encompasses two main steps: Step 2 (Cont’d): If any other record is encountered Add the corresponding transaction to the Transaction table (if it is not already there) Set lastLSN to the LSN of the record Set status to C for committed transactions, or to U (i.e., Undo), otherwise When an update log record is encountered If the recorded page, P, is not in the Dirty Page table Add P to the Dirty Page table and set its recLSN to the LSN of the log record

ARIES: The Analysis Phase At the end of the Analysis phase: The Transaction table contains an “accurate” list of all transactions that were active at the time of the crash The Dirty Page table contains all pages that were dirty at the time of the crash These pages may contain some pages that were written to disk (why?)– Not a Problem!

ARIES: The Redo Phase During the Redo phase, ARIES reapplies the updates of “all” transactions (i.e., committed and aborted) This paradigm is referred to as Repeating History The Redo phase scans forward until the end of the log, and redoes every action unless: The affected page is not in the Dirty Page table The affected page is in the Dirty Page table, but its recLSN > the current record’s LSN The pageLSN of the affected page >= the current record’s LSN Wouldn’t checking this be enough?

ARIES: The Redo Phase During the Redo phase, ARIES reapplies the updates of “all” transactions (i.e., committed and aborted) This paradigm is referred to as Repeating History The Redo phase scans forward until the end of the log, and redoes every action unless: The affected page is not in the Dirty Page table The affected page is in the Dirty Page table, but its recLSN > the current record’s LSN The pageLSN of the affected page >= the current record’s LSN YES, but it requires retrieving the page from the disk, thus made last!

ARIES: The Redo Phase If the logged action must be redone: The logged action is reapplied The pageLSN on the page is set to the LSN of the redone log record No additional record is written at this time!

ARIES: The Undo Phase This phase will undo the actions of all transactions that were active before the crash These transactions are referred to as loser transactions and were identified by the Analysis phase The Undo phase: Considers the set of lastLSN values for all loser transactions This is denoted as the ToUndo set Repeatedly chooses the largest (i.e., the most recent) LSN value in ToUndo and processes it, until ToUndo is empty

ARIES: The Undo Phase In particular, the Undo phase proceeds as follows: Repeat: Choose largest LSN among ToUndo If this LSN is a CLR and undoNextLSN==NULL Write an End record for this Xact If this LSN is a CLR, and undoNextLSN != NULL Add undonextLSN to ToUndo Else this LSN is an update Undo the update Write a CLR Add prevLSN to ToUndo Until ToUndo is empty

An Example LSN LOG 00,05 10 20 30 40,45 50 60 70 80,85 90 begin_checkpoint, end_checkpoint update: T1 writes P5 update T2 writes P3 T1 abort CLR: Undo T1 LSN 10, T1 End update: T3 writes P1 update: T2 writes P5 CRASH, RESTART CLR: Undo T2 LSN 60 CLR: Undo T3 LSN 50, T3 end CLR: Undo T2 LSN 20, T2 end prevLSN undoNextLSN

Additional Crash Issues What happens if the system crashes while “Restart” is in the Analysis phase? All the work done is lost! On a second Restart, the Analysis phase starts afresh What happens if the system crashes while “Restart” is in the Redo phase? Restart starts again with the Analysis phase then the Redo phase But, some of the changes made during Redo may have been written to disk The update log records that were done the first time around will not be redone a second time (why?)

Summary Recovery Manager guarantees Atomicity & Durability WAL is used to allow STEAL/NO-FORCE without sacrificing correctness LSNs identify log records; linked into backwards chains per transaction (via prevLSN) pageLSNs allow comparisons of data pages and log records

Summary Checkpointing: A quick way to limit the amount of log to scan on recovery Recovery works in 3 phases: Analysis: Forward from checkpoint Redo: Forward from oldest recLSN Undo: Backward from end to first LSN of oldest transaction alive at crash Upon Undo, write CLRs Redo “repeats history”: Simplifies the logic!

Next Class The NoSQL Movement!