1 Lecture 15: Data Storage, Recovery Monday, February 13, 2006.

Slides:



Advertisements
Similar presentations
Storing Data: Disk Organization and I/O
Advertisements

1 Lecture 12: Transactions: Recovery. 2 Outline Recovery Undo Logging Redo Logging Undo/Redo Logging Book Section 15.1, 15.2, 23, 24, 25.
CS 245Notes 081 CS 245: Database System Principles Notes 08: Failure Recovery Hector Garcia-Molina.
1 CSIS 7102 Spring 2004 Lecture 8: Recovery (overview) Dr. King-Ip Lin.
Recovery CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
CSCI 3140 Module 8 – Database Recovery Theodore Chiasson Dalhousie University.
Transactions A process that reads or modifies the DB is called a transaction. It is a unit of execution of database operations. Basic JDBC transaction.
Recovery from Crashes. Transactions A process that reads or modifies the DB is called a transaction. It is a unit of execution of database operations.
1 Lecture 4: Transactions Wednesday, October 20, 2010 Dan Suciu -- CSEP544 Fall 2010.
Crash Recovery. Review: The ACID properties A A tomicity: All actions in the Xaction happen, or none happen. C C onsistency: If each Xaction is consistent,
Recovery from Crashes. ACID A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction,
1 ICS 214A: Database Management Systems Fall 2002 Lecture 16: Crash Recovery Professor Chen Li.
ACID A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction, may change the DB from.
1 Lecture 12: Transactions: Recovery. 2 Outline Recovery Undo Logging Redo Logging Undo/Redo Logging Book Section 15.1, 15.2, 23, 24, 25.
Cs4432recovery1 CS4432: Database Systems II Database Consistency and Violations?
Transactions A process that reads or modifies the DB is called a transaction. It is a unit of execution of database operations. Basic JDBC transaction.
Cs4432recovery1 CS4432: Database Systems II Lecture #20 Failure Recovery Professor Elke A. Rundensteiner.
CS 245Notes 081 CS 245: Database System Principles Notes 08: Failure Recovery Hector Garcia-Molina.
©Silberschatz, Korth and Sudarshan17.1Database System Concepts 3 rd Edition Chapter 17: Recovery System Failure Classification Storage Structure Recovery.
M.P. Johnson, DBMS, Stern/NYU, Sp20041 C : Database Management Systems Lecture #26 Matthew P. Johnson Stern School of Business, NYU Spring, 2004.
July 16, 2015ICS 5411 Coping With System Failure Chapter 17 of GUW.
TRANSACTIONS A sequence of SQL statements to be executed "together“ as a unit: A money transfer transaction: Reasons for Transactions : Concurrency control.
1 Recovery Control (Chapter 17) Redo Logging CS4432: Database Systems II.
1 CPS216: Advanced Database Systems Notes 10: Failure Recovery Shivnath Babu.
Layers of a DBMS Query optimization Execution engine Files and access methods Buffer management Disk space management Query Processor Query execution plan.
Lecture 11: DMBS Internals
Lecture #19 May 13 th, Agenda Trip Report End of constraints: triggers. Systems aspects of SQL – read chapter 8 in the book. Going under the lid!
1 Lecture 14: Transactions in SQL Monday, October 30, 2006.
CS411 Database Systems Kazuhiro Minami 14: Concurrency Control.
1 Transaction Management. 2 Outline Transaction management –motivation & brief introduction –major issues recovery concurrency control Recovery.
HANDLING FAILURES. Warning This is a first draft I welcome your corrections.
CMPT 454, Simon Fraser University, Fall 2009, Martin Ester 294 Database Systems II Coping With System Failures.
Recovery System By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
DBMS 2001Notes 7: Crash Recovery1 Principles of Database Management Systems 7: Crash Recovery Pekka Kilpeläinen (after Stanford CS245 slide originals.
Chapter 16 Recovery Yonsei University 1 st Semester, 2015 Sanghyun Park.
Concurrency Control. Objectives Management of Databases Concurrency Control Database Recovery Database Security Database Administration.
DMBS Internals I. What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently.
Chapter 17: Recovery System
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 17: Recovery System.
1 CSE544 Transactions: Recovery Thursday, January 27, 2011 Dan Suciu , Winter 2011.
DMBS Internals I February 24 th, What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the.
DMBS Internals I. What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently.
DMBS Architecture May 15 th, Generic Architecture Query compiler/optimizer Execution engine Index/record mgr. Buffer manager Storage manager storage.
1 Ullman et al. : Database System Principles Notes 08: Failure Recovery.
1 Lecture 28: Recovery Friday, December 5 th, 2003.
Chapter 81 Chapter 8 Coping With System Failures Spring 2001 Prof. Sang Ho Lee School of Computing, Soongsil Univ.
What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently and safely. Provide.
1 Lecture 16: Data Storage Wednesday, November 6, 2006.
1 Advanced Database Systems: DBS CB, 2 nd Edition Recovery Ch. 17.
Database Recovery Techniques
Recovery Control (Chapter 17)
Lecture 13: Recovery Wednesday, February 2, 2005.
Advanced Database Systems: DBS CB, 2nd Edition
Recovery 6/4/2018.
Lecture 16: Data Storage Wednesday, November 6, 2006.
CSE544: Transactions Recovery Wednesday, 4/19/2006.
CS4432: Database Systems II
File Processing : Recovery
Lecture 11: DMBS Internals
Lecture 15: Midterm Review Data Storage
Lecture 28 Friday, December 7, 2001.
Recovery System.
Introduction to Database Systems CSE 444 Lectures 15-16: Recovery
Introduction to Database Systems CSE 444 Lecture 14: Transactions in SQL October 26, 2007.
CPSC-608 Database Systems
Lecture 18: DMBS Overview and Data Storage
Data-intensive Computing Systems Failure Recovery
Lecture 17: Data Storage and Recovery
Lecture 16: Recovery Friday, November 4, 2005.
Lecture 15: Data Storage Tuesday, February 20, 2001.
Presentation transcript:

1 Lecture 15: Data Storage, Recovery Monday, February 13, 2006

2 Outline Disks 11.3 –Recommended reading: entire chapter 11 Recovery using undo logging 17.2

3 The Mechanics of Disk Mechanical characteristics: Rotation speed (5400RPM) Number of platters (1-30) Number of tracks (<=10000) Number of bytes/track(10 5 ) Platters Spindle Disk head Arm movement Arm assembly Tracks Sector Cylinder Unit of read or write: disk block Once in memory: page Typically: 4k or 8k or 16k

4 Disk Access Characteristics Disk latency = time between when command is issued and when data is in memory Disk latency = seek time + rotational latency –Seek time = time for the head to reach cylinder 10ms – 40ms –Rotational latency = time for the sector to rotate Rotation time = 10ms Average latency = 10ms/2 Transfer time = typically 40MB/s Disks read/write one block at a time

5 RAID Several disks that work in parallel Redundancy: use parity to recover from disk failure Speed: read from several disks at once Various configurations (called levels): RAID 1 = mirror RAID 4 = n disks + 1 parity disk RAID 5 = n+1 disks, assign parity blocks round robin RAID 6 = “Hamming codes”

6 Buffer Management in a DBMS Data must be in RAM for DBMS to operate on it! Table of pairs is maintained DB MAIN MEMORY DISK disk page free frame Page Requests from Higher Levels BUFFER POOL choice of frame dictated by replacement policy READ WRITE INPUT OUTUPT

7 Buffer Manager Needs to decide on page replacement policy LRU Clock algorithm Both work well in OS, but not always in DB Enables the higher levels of the DBMS to assume that the needed data is in main memory.

8 Least Recently Used (LRU) Order pages by the time of last accessed Always replace the least recently accessed P5, P2, P8, P4, P1, P9, P6, P3, P7 Access P6 P6, P5, P2, P8, P4, P1, P9, P3, P7 LRU is expensive (why ?); the clock algorithm is good approx

9 Buffer Manager Why not use the Operating System for the task?? - DBMS may be able to anticipate access patterns - Hence, may also be able to perform prefetching -DBMS needs the ability to force pages to disk, for recovery purposes - need fine grained control for transactions

10 Transaction Management Two parts: Recovery from crashes: ACID Concurrency control: ACID Both operate on the buffer pool

11 Recovery From which of the events below can a database actually recover ? Wrong data entry Disk failure Fire / earthquake / bankrupcy / …. Systems crashes

12 Recovery Type of CrashPrevention Wrong data entry Constraints and Data cleaning Disk crashes Redundancy: e.g. RAID, archive Fire, theft, bankruptcy… Buy insurance, Change jobs… System failures: e.g. power DATABASE RECOVERY Most frequent

13 System Failures Each transaction has internal state When system crashes, internal state is lost –Don’t know which parts executed and which didn’t Remedy: use a log –A file that records every single action of the transaction

14 Transactions Assumption: the database is composed of elements –Usually 1 element = 1 block –Can be smaller (=1 record) or larger (=1 relation) Assumption: each transaction reads/writes some elements

15 Primitive Operations of Transactions READ(X,t) –copy element X to transaction local variable t WRITE(X,t) –copy transaction local variable t to element X INPUT(X) –read element X to memory buffer OUTPUT(X) –write element X to disk

16 Example START TRANSACTION READ(A,t); t := t*2; WRITE(A,t); READ(B,t); t := t*2; WRITE(B,t) COMMIT; START TRANSACTION READ(A,t); t := t*2; WRITE(A,t); READ(B,t); t := t*2; WRITE(B,t) COMMIT; Atomicity: BOTH A and B are multiplied by 2

17 ActiontMem AMem BDisk ADisk B INPUT(A)888 READ(A,t)8888 t:=t* WRITE(A,t)16 88 INPUT(B) READ(B,t) t:=t* WRITE(B,t)16 88 OUTPUT(A)16 8 OUTPUT(B)16 Buffer poolDiskTransaction READ(A,t); t := t*2; WRITE(A,t); READ(B,t); t := t*2; WRITE(B,t) READ(A,t); t := t*2; WRITE(A,t); READ(B,t); t := t*2; WRITE(B,t)

18 ActiontMem AMem BDisk ADisk B INPUT(A)888 READ(A,t)8888 t:=t* WRITE(A,t)16 88 INPUT(B) READ(B,t) t:=t* WRITE(B,t)16 88 OUTPUT(A)16 8 OUTPUT(B)16 Crash ! Crash occurs after OUTPUT(A), before OUTPUT(B) We lose atomicity

19 The Log An append-only file containing log records Note: multiple transactions run concurrently, log records are interleaved After a system crash, use log to: –Redo some transaction that didn’t commit –Undo other transactions that didn’t commit Three kinds of logs: undo, redo, undo/redo

20 Undo Logging Log records –transaction T has begun –T has committed –T has aborted –T has updated element X, and its old value was v

21 ActionTMem AMem BDisk ADisk BLog INPUT(A)888 READ(A,t)8888 t:=t* WRITE(A,t)16 88 INPUT(B) READ(B,t) t:=t* WRITE(B,t)16 88 OUTPUT(A)16 8 OUTPUT(B)16 COMMIT

22 ActionTMem AMem BDisk ADisk BLog INPUT(A)888 READ(A,t)8888 t:=t* WRITE(A,t)16 88 INPUT(B) READ(B,t) t:=t* WRITE(B,t)16 88 OUTPUT(A)16 8 OUTPUT(B)16 COMMIT Crash ! WHAT DO WE DO ?

23 ActionTMem AMem BDisk ADisk BLog INPUT(A)888 READ(A,t)8888 t:=t* WRITE(A,t)16 88 INPUT(B) READ(B,t) t:=t* WRITE(B,t)16 88 OUTPUT(A)16 8 OUTPUT(B)16 COMMIT Crash ! WHAT DO WE DO ?

24 After Crash In the first example: –We UNDO both changes: A=8, B=8 –The transaction is atomic, since none of its actions has been executed In the second example –We don’t undo anything –The transaction is atomic, since both it’s actions have been executed

25 Undo-Logging Rules U1: If T modifies X, then must be written to disk before OUTPUT(X) U2: If T commits, then OUTPUT(X) must be written to disk before Hence: OUTPUTs are done early, before the transaction commits

26 ActionTMem AMem BDisk ADisk BLog INPUT(A)888 READ(A,t)8888 t:=t* WRITE(A,t)16 88 INPUT(B) READ(B,t) t:=t* WRITE(B,t)16 88 OUTPUT(A)16 8 OUTPUT(B)16 COMMIT

27 Recovery with Undo Log After system’s crash, run recovery manager Idea 1. Decide for each transaction T whether it is completed or not – …. …. = yes – …. ……. = yes – ……………………… = no Idea 2. Undo all modifications by incomplete transactions

28 Recovery with Undo Log Recovery manager: Read log from the end; cases: : mark T as completed : if T is not completed then write X=v to disk else ignore : ignore

29 Recovery with Undo Log … … Question1 in class: Which updates are undone ? Question 2 in class: How far back do we need to read in the log ? crash

30 Recovery with Undo Log Note: all undo commands are idempotent –If we perform them a second time, no harm is done –E.g. if there is a system crash during recovery, simply restart recovery from scratch

31 Recovery with Undo Log When do we stop reading the log ? We cannot stop until we reach the beginning of the log file This is impractical Instead: use checkpointing