CSF212 Module7
CSF212 Module7
CSF212 Module7
• Recovery Concepts
• Log-based Recovery Techniques
• Shadow Paging
• ARIES Recovery Algorithm
9
BITS Pilani, Pilani Campus
Transaction Rollback and
Cascading Rollback
• If a transaction fails for whatever reason after updating the
database, but before the transaction commits, it may be necessary
to roll back the transaction.
• If any data item values have been changed by the transaction and
written to the database, they must be restored to their previous
values (BFIMs). The undo-type log entries are used to restore the
old values of data items that must be rolled back.
• If a transaction T is rolled back, any transaction S that has, in the
interim, read the value of some data item X written by T must also
be rolled back.
• Similarly, once S is rolled back, any transaction R that has read the
value of some data item Y written by S must also be rolled back; and
so on. This phenomenon is called cascading rollback , and can occur
when the recovery protocol ensures recoverable schedules but does
not ensure strict or cascadeless schedules 10
BITS Pilani, Pilani Campus
11
BITS Pilani, Pilani Campus
12
BITS Pilani, Pilani Campus
Recovery Techniques Based
on Deferred Update
16
BITS Pilani, Pilani Campus
Example
17
BITS Pilani, Pilani Campus
Example
18
BITS Pilani, Pilani Campus
Recovery Techniques Based
on Immediate Update
24
BITS Pilani, Pilani Campus
Shadow Paging
• To recover from a failure during transaction execution, it is
sufficient to free the modified database pages and to
discard the current directory.
• The state of the database before transaction execution is
available through the shadow directory, and that state is
recovered by reinstating the shadow directory.
• The database thus is returned to its state prior to the
transaction that was executing when the crash occurred,
and any modified pages are discarded.
• Committing a transaction corresponds to discarding the
previous shadow directory. Since recovery involves neither
undoing nor redoing data items, this technique can be
categorized as a NO-UNDO/ NO-REDO technique for 25
recovery. BITS Pilani, Pilani Campus
Disadvantages
• One disadvantage of shadow paging is that the
updated database pages change location on disk.
This makes it difficult to keep related database pages
close together on disk without complex storage
management strategies.
• Furthermore, if the directory is large, the overhead
of writing shadow directories to disk as transactions
commit is significant.
• A further complication is how to handle garbage
collection when a transaction commits.
26
BITS Pilani, Pilani Campus
ARIES Recovery Algorithm
29
BITS Pilani, Pilani Campus
Recovery Procedure
• Finally, during the UNDO phase, the log is scanned
backward and the operations of transactions that were
active at the time of the crash are undone in reverse order.
The information needed for ARIES to accomplish its
recovery procedure includes the log, the Transaction Table,
and the Dirty Page Table. Additionally, checkpointing is
used.
• These tables are maintained by the transaction manager
and written to the log during checkpointing.
• In ARIES, every log record has an associated log sequence
number (LSN) that is monotonically increasing and indicates
the address of the log record on disk.
30
BITS Pilani, Pilani Campus
Log Sequence Number
Each LSN corresponds to a specific change (action) of some
transaction. Also, each data page will store the LSN of the
latest log record corresponding to a change for that page.
A log record is written for any of the following actions:
updating a page (write), committing a transaction (commit),
aborting a transaction (abort), undoing an update (undo), and
ending a transaction (end). The need for including the first
three actions in the log has been discussed, but the last two
need some explanation.
When an update is undone, a compensation log record is
written in the log. When a transaction ends, whether by
committing or aborting, an end log record is written.
31
BITS Pilani, Pilani Campus
An example of recovery in ARIES
(a) The log at point of crash.
32
BITS Pilani, Pilani Campus
Continued…
(b)The Transaction and Dirty Page Tables at time of checkpoint.
(c)The Transaction and Dirty Page Tables after the analysis
phase.
33
BITS Pilani, Pilani Campus