30-06-2012, 03:56 PM
Database System Recovery
DBRecovery.ppt (Size: 126.5 KB / Downloads: 197)
Introduction
All database reads/writes are within a transaction
Transactions have the “ACID” properties
Atomicity - all or nothing
Consistency - preserves database integrity
Isolation - execute as if they were run alone
Durability - results aren’t lost by a failure
Recovery subsystem guarantees A & D
Concurrency control guarantees I
Application program guarantees C
Recovery Goals
A database may become inconsistent because of a
transaction failure (abort)
database system failure (possibly caused by OS crash)
media crash (disk-resident data is corrupted)
The recovery system ensures the database contains exactly those updates produced by committed transactions
I.e. atomicity and durability, despite failures
Stable Storage
Write(P) overwrites the entire contents of P on the disk
If Write is unsuccessful, the error might be detected on the next read ...
e.g. page checksum error => page is corrupted
… or maybe not
Write correctly wrote to the wrong location
Write is the only operation that’s atomic with respect to failures and whose successful execution can be determined by recovery procedures.
The Log
A sequential file of records describing updates:
address of updated page
id of transaction that did the update
before-image and after-image of the page
Whenever you update the cache, also update the log
Log records for Commit(Ti) and Abort(Ti)
Some older systems separated before-images and after-images into separate log files.
If opi conflicts with and executes before opk, then opi’s log record must precede opk’s log record
recovery will replay operations in log record order
Avoiding Undo
Avoid the problem implied by the Undo Rule by never flushing uncommitted updates.
Avoids stable logging of before-images
Don’t need to undo updates after a system failure
A recovery algorithm requires undo if an update of an uncommitted transaction can be flushed.
Usually called a steal algorithm, because it allows a dirty cache page to be “stolen.”