Module 5 - Recovery & Atomicity
Module 5 - Recovery & Atomicity
Failure Classification
Storage Structure
Recovery and Atomicity
Log-Based Recovery
Shadow Paging
Recovery With Concurrent Transactions
Buffer Management
Failure with Loss of Nonvolatile Storage
Advanced Recovery Techniques
ARIES Recovery Algorithm
Remote Backup Systems
Failure Classification
Transaction failure :
Logical errors: transaction cannot complete due to some internal
error condition
System errors: the database system must terminate an active
transaction due to an error condition (e.g., deadlock)
System crash: a power failure or other hardware or software
failure causes the system to crash.
Fail-stop assumption: non-volatile storage contents are assumed
to not be corrupted by system crash
Database systems have numerous integrity checks to prevent
corruption of disk data
Disk failure: a head crash or similar disk failure destroys all or
part of disk storage
Destruction is assumed to be detectable: disk drives use checksums
to detect failures
Recovery Algorithms
Volatile storage:
does not survive system crashes
examples: main memory, cache 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 distinct nonvolatile
media
Stable-Storage Implementation
Buffer Block B Y A
output(B) B
read(X)
write(Y)
x2 disk
x1
y1
<T0 start>
<T0, A, 1000, 950>
To, B, 2000, 2050
A = 950
B = 2050
<T0 commit>
x1
<T1 start>
<T1, C, 700, 600>
C = 600
B B , BC
<T1 commit>
BA
Note: BX denotes block containing X.
Immediate Database Modification (Cont.)
Recovery procedure has two operations instead of one:
undo(Ti) restores the value of all data items updated by Ti to their old
values, going backwards from the last log record for Ti
redo(Ti) sets the value of all data items updated by Ti to the new
values, going forward from the first log record for Ti
Both operations must be idempotent
That is, even if the operation is executed multiple times the effect is
the same as if it is executed once
Needed since operations may get re-executed during recovery
When recovering after failure:
Transaction Ti needs to be undone if the log contains the record
<Ti start>, but does not contain the record <Ti commit>.
Transaction Ti needs to be redone if the log contains both the record
<Ti start> and the record <Ti commit>.
Undo operations are performed first, then redo operations.
Immediate DB Modification Recovery
Example
Below we show the log as it appears at three instances of time.
Tc Tf
T1
T2
T3
T4
T2 and T3 redone.
T4 undone
Shadow Paging