Session 19 Recovery
Session 19 Recovery
Session 19
Academic year 2024-2025
Physical blocks
<T0 start>
<T0, A, 1000, 950>
<T0, B, 2000, 2050>
A = 950
B = 2050
<T0 commit>
<T1 start> BlockC output
<T1, C, 700, 600> before T1 commits
C = 600
BlockB , BlockC
<T1 commit> BlockA output
BlockA after T0 commits
Recovering from a failure
• Undo and Redo of Transactions
• 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
• Each time a data item X is restored to its old value V a special log record <Ti , X, V>
is written out
• When undo of a transaction is complete, a log record
<Ti abort> is written out.
• 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
• No logging is done in this case
undo (T0)
B is restored to 2000 and A to 1000
log records
<T0, B, 2000>, <T0, A, 1000>, <T0, abort> are written out
Inmediate DB modification Recovery Example
redo (T0)
A and B are set to 950 and 2050
undo (T1)
C is restored to 700
Log records <T1, C, 700>, <T1, abort> are written out.
Inmediate DB modification Recovery Example
redo (T0)
A is set to 950
B is set to 2050
redo (T1)
C is set to 600
Checkpoints
• Rationale
• Processing the entire log is time-consuming if the
system has run for a long time
• Unnecessarily redo transactions that have
already output their updates to the DB
• Periodically checkpoints as agile recovery procedure
• Detection of failure. Backup site must detect when primary site has failed
• Heart-beat messages
• Transfer of control
• To take over control backup site first perform recovery using its copy of the database
and all the log records it has received from the primary. Completed transactions are
redone and incomplete transactions are rolled back. After it, it becomes the new
primary
• To transfer control back to old primary when it recovers, old primary must receive
redo logs from the old backup and apply all updates locally.
Remote Backup systems
• Time to recover. To reduce delay in takeover, backup site periodically process the redo
log records, performs a checkpoint, and can then delete earlier parts of the log
• Time to commit. To ensure that the updates of a committed transaction are durable, a
transaction should not be announced committed until its log records have reached the
backup site