Académique Documents
Professionnel Documents
Culture Documents
Chapter 23
1
What is Database Recovery
2
Kind of failures a database system
may encounter
Transaction failure
System failure
Disk failure
Catastrophic failure
3
Transaction failure
4
System failure
5
Disk failure
6
Catastrophic failure
Power failure
Air conditioning failure
Fire
Theft
Sabotage
Overwriting disk
Mounting a wrong tape
Tsunami
Hurricane
7
State transition diagram illustrating the states for
transaction execution
8
States for transaction execution
9
States for transaction execution
10
System log
(Data structure required for recovery)
11
System log
[start_transaction, T]
[read_item, T, X]
[commit, T]
[abort, T]
Log is stored on disk with its last part (most recent part) residing in DBMS
cache.
Part of the log residing in the DBMS cache is called log buffer.
12
System log (an example)
[start_transaction, T1]
[read_item, T1, X]
[write_item, T1, X, 12000, 7000]
[read_item, T1, Y]
[write_item, T1, Y, 20000, 25000]
[commit, T1]
[start_transaction, T2]
[read_item, T2, X]
[write_item, T2, X, 12000, 19000]
[commit, T2]
13
System log (another instance)
System log?
14
Commit point of a transaction
15
Data update
(Flushing cached data to disk database)
Deferred update
All modified data items in the cache are written
to the disk either after a transaction commits or
after a fixed number of transactions have
committed.
Immediate update
Modified data item can be written to the disk
before the transaction commits.
16
Data update
In-place update
The disk version of the data item is overwritten by its
cache version.
Shadow update
The modified version of a data item does not
overwrite its disk copy but is written at a separate
disk location.
17
Data caching
18
Rollback (Undo) & Roll forward (Redo)
20
Write-ahead logging (WAL)
21
Write-ahead logging (WAL) protocol
22
WAL protocol
24
Checkpoint
25
Checkpoint
27
Checkpoint record & its effect
28
Steal/No-steal & Force/No-force
Steal:
Modified data items can be written to the disk
before transaction commits.
No-steal:
Modified data items cannot be written to the disk
before transaction commits.
29
Force/No-force
Force:
All modified data items must be written to the disk
before the transaction commits.
No-force:
All modified data items need not be written to the
disk before the transaction commits.
30
Alternative strategies of Recovery Manager
Steal/Force (Undo/No-redo)
Steal/No-force (Undo/Redo) (ARIES uses)
No-steal/Force (No-undo/No-redo)
No-steal/No-force (No-undo/Redo)
31
Recovery scheme based on deferred update
32
Deferred update in a single-user system
33
A serial schedule & system log with deferred
update
34
Recovery based on deferred update with
concurrent users & a checkpoint (an example)
35
System log at the time of crash
36
Recovery based on deferred update with
concurrent users & a checkpoint
38
Recovery technique based on immediate update
39
Shadow paging
This recovery scheme does not require the use of a log in a single-user
environment. In a multiuser environment, a log may be needed for the
concurrency control method.
Shadow paging considers the database to be made up of a number of
fixed size disk pages (or disk blocks)—say, n—for recovery purposes.
A directory with n entries is constructed, where the ith entry points to
the ith database page on disk. The directory is kept in main memory if it
is not too large, and all references—reads or writes—to database
pages on disk go through it.
When a transaction begins executing, the current directory — whose
entries point to the most recent or current database pages on disk —
is copied into a shadow directory. The shadow directory is then saved
on disk while the current directory is used by the transaction.
40
Shadow paging
41
Shadow paging
42
Shadow paging (an example)
43
ARIES recovery algorithm
ARIES
Algorithm for Recovery and Isolation Exploiting Semantics.
ARIES uses Steal/No-force approach for writing.
ARIES is based on:
Write ahead logging (WAL)
Repeating history during redo
Logging changes during undo
44
Repeating history during redo
45
Logging changes during undo
46
ARIES
47
Data structure required in ARIES
Log table
48
Log table, TT & DPT
50
TT & DPT after Analysis phase
Record in log table
51
Transaction table & Dirty page table
52
Check pointing by ARIES
53
Analysis phase
54
Redo phase
M = min(DPT.LSN)
55
Undo phase
Find out the active transactions with the highest LSN from TT.
Start from this LSN and move backward in the log table
undoing changes until every action of the set of active
transactions has been undone.
56
Database Recovery
(Summary)
Types of failure
Transaction log
Data update
Data caching
Transaction Rollback (undo) & Roll forward (redo)
Write-ahead logging (WAL) protocol
Checkpoint
Steal/No-steal & Force/No-force
Recovery scheme based on deferred update
Recovery scheme based on immediate update
ARIES
57