l25_ppt_ivsem
TRANSCRIPT
-
8/18/2019 L25_PPT_IVSem
1/15
Lecture 25Lecture 25
Recovery SystemRecovery System
©Silberschatz, Korth and Sudarshan
See www.db-book.com for conditions on re-use
-
8/18/2019 L25_PPT_IVSem
2/15
Recovery SystemRecovery System
Failure Classification
Storage Structure
ecovery an tom c ty
Log-Based Recovery
Shadow Paging
Recovery With Concurrent Transactions
Buffer Management
Advanced Recovery Techniques
ARIES Recovery Algorithm
Remote Backup Systems
©Silberschatz, Korth and Sudarshan17.2Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
3/15
-
8/18/2019 L25_PPT_IVSem
4/15
Recovery AlgorithmsRecovery Algorithms
Recovery algorithms are techniques to ensure database consistencyand transaction atomicity and durability despite failures
Recovery algorithms have two parts1. Actions taken during normal transaction processing to ensure
2. Actions taken after a failure to recover the database contents to a
state that ensures atomicity, consistency and durability
©Silberschatz, Korth and Sudarshan17.4Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
5/15
Storage StructureStorage Structure
Volatile storage :
does not survive system crashes
examp es: ma n memory, cac e memory
Nonvolatile storage :
survives system crashes
examples: disk, tape, flash memory,non-volatile (battery backed up) RAM
Stable storage :
a mythical form of storage that survives all failures
approximated by maintaining multiple copies on distinctnonvolatile media
©Silberschatz, Korth and Sudarshan17.5Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
6/15
StableStable- -Storage ImplementationStorage Implementation
Maintain multiple copies of each block on separate diskscopies can be at remote sites to protect against disasters such asfire or flooding.
Failure during data transfer can still result in inconsistent copies: Blocktransfer can result inSuccessful completionPartial failure: destination block has incorrect informationTotal failure: destination block was never updated
Protecting storage media from failure during data transfer (onesolution):
Execute output operation as follows (assuming two copies of eachblock):
1. Write the information onto the first physical block.2. When the first write successfully completes, write the same
information onto the second physical block.
©Silberschatz, Korth and Sudarshan17.6Database System Concepts, 5 th Edition, Oct 5, 2006
3. e ou pu s comp e e on y a er e secon wr esuccessfully completes.
-
8/18/2019 L25_PPT_IVSem
7/15
StableStable- -Storage Implementation (Cont.)Storage Implementation (Cont.)
Protecting storage media from failure during data transfer (cont.):
Copies of a block may differ due to failure during output operation. To
1. First find inconsistent blocks:1. Expensive solution : Compare the two copies of every disk block.
2. Better solution :
Record in-progress disk writes on non-volatile storage (Non-volatile RAM or special area of disk).Use this information during recovery to find blocks that may be
inconsistent, and only compare copies of these.
Used in hardware RAID systems
2. If either copy of an inconsistent block is detected to have an error (badchecksum), overwrite it by the other copy. If both have no error, but aredifferent, overwrite the second block by the first block.
©Silberschatz, Korth and Sudarshan17.7Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
8/15
Data AccessData Access
Physical blocks are those blocks residing on the disk.
Buffer blocks are the blocks residing temporarily in main memory.
oc movemen s e ween s an ma n memory are n a e
through the following two operations:input (B) transfers the physical block B to main memory.
output (B) transfers the buffer block B to the disk, and replaces theappropriate physical block there.
Each transaction Ti has its private work-area in which local copies ofa a a ems accesse an up a e y are ep .
Ti's local copy of a data item X is called xi.
We assume, for simplicity, that each data item fits in, and is stored
ns e, a s ng e oc .
©Silberschatz, Korth and Sudarshan17.8Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
9/15
-
8/18/2019 L25_PPT_IVSem
10/15
Recovery and AtomicityRecovery and Atomicity
Modifying the database without ensuring that the transaction will commitmay leave the database in an inconsistent state.
i
goal is either to perform all database modifications made by Ti or noneat all.
Several out ut o erations ma be re uired for T to out ut A and B . A failure may occur after one of these modifications have been made butbefore all of them are made.
©Silberschatz, Korth and Sudarshan17.10Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
11/15
Recovery and Atomicity (Cont.)Recovery and Atomicity (Cont.)
To ensure atomicity despite failures, we first output informationdescribing the modifications to stable storage without modifying thedatabase itself.
We study two approaches:log-based recovery , and
-
We assume (initially) that transactions run serially, that is, one after
the other.
©Silberschatz, Korth and Sudarshan17.11Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
12/15
LogLog--Based RecoveryBased Recovery
A log is kept on stable storage.The log is a sequence of log records , and maintains a record ofu date activities on the database.
When transaction Ti starts, it registers itself by writing alog recordBefore T i executes write (X), a log record is written,where V1 is the value of X before the write, and V2 is the value to bewritten to X.
Log record notes that Ti has performed a write on data item X j X j , .When Ti finishes it last statement, the log record < Ti commi t> is written.We assume for now that log records are written directly to stablestora e that is the are not bufferedTwo approaches using logs
Deferred database modification
©Silberschatz, Korth and Sudarshan17.12Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
13/15
CheckpointsCheckpoints
Problems in recovery procedure
searching the entire log is time-consuming
1. we m g unnecessar y re o ransac ons w c ave a rea y
2. output their updates to the database.Streamline recovery procedure by periodically performingcheckpointing
1. Output all log records currently residing in main memory onto
stable storage.2. Output all modified buffer blocks to the disk.
3. Write a log record < checkpoint > onto stable storage.
©Silberschatz, Korth and Sudarshan17.13Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
14/15
Checkpoints (Cont.)Checkpoints (Cont.)
During recovery we need to consider only the most recent transactionTi that started before the checkpoint, and transactions that startedafter Ti.
1. Scan backwards from end of log to find the most recent record
2. Continue scannin backwards till a record is found.
3. Need only consider the part of log following above star t record.Earlier part of log can be ignored during recovery, and can beerased whenever desired.
4. For all transactions (starting from Ti or later) with no ,execute undo (Ti). (Done only in case of immediate modification.)
5. Scanning forward in the log, for all transactions startingfrom Ti or later with a , execute redo (Ti).
©Silberschatz, Korth and Sudarshan17.14Database System Concepts, 5 th Edition, Oct 5, 2006
-
8/18/2019 L25_PPT_IVSem
15/15
Example of CheckpointsExample of Checkpoints
Tc Tf
T2T3
T4
T1 can be ignored (updates already output to disk due to checkpoint)
T and T redone.
checkpoint sys em a ure
T4 undone
©Silberschatz, Korth and Sudarshan17.15Database System Concepts, 5 th Edition, Oct 5, 2006