Crash Recovery - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Crash Recovery

Description:

Undo is initiated. End ... before the action recorded in Update log record is undone. ... Start log record that don't have Commit log record are undone ... – PowerPoint PPT presentation

Number of Views:129
Avg rating:3.0/5.0
Slides: 24
Provided by: Mari630
Category:

less

Transcript and Presenter's Notes

Title: Crash Recovery


1
Crash Recovery
  • Chapter 22.3

2
Buffers
  • Main memory locations which are used to transfer
    data to and from secondary storage
  • Dirty bit and dirty page
  • Dirty bit and pinCount are initially set to 0
  • Replacement strategies
  • First-in-first-out (FIFO)
  • Least recently used (LRU)

3
Buffer management
  • A steal policy buffer manager writes a buffer to
    disk before a transaction commits
  • Alternative policy no-steal
  • A force policy all pages updated by a
    transaction are immediately written to disk when
    the transaction commits.
  • Alternative policy no-force

4
Recovery Facilities
  • Backup mechanism
  • Logging
  • Checkpoints
  • Recovery algorithms

5
The Log
  • History of actions executed by the DBMS
  • Stable storage
  • Log tail
  • Actions are recorded in chronological order

6
Log Sequence Number
  • Monotonically increasing order
  • Every page (object) contains pageLSN
  • PageLSN - the most recent LSN from the log

7
Actions recorded to the Log
  • Start
  • Updating an object
  • Update record is appended to the log tail
  • pageLSN is set to the current LSN
  • Commit
  • Commit record is appended to the log
  • Log tail is written to stable storage

8
Actions recorded to the Log (cont)
  • Abort
  • Abort log record is appended to the log
  • Undo is initiated
  • End
  • Undoing updates
  • After the action described in update log record
    is undone, a compensation log record (CLR) is
    appended to the log.

9
Update Log Record
  • Common fields for all log records
  • LSN, prevLSN, transID, type
  • Fields for update records only
  • PageID
  • Length of changes in bytes
  • Offset (start byte)
  • Before-image
  • After-image

10
Compensation Log Record
  • Is written just before the action recorded in
    Update log record is undone.
  • The same fields as for Update record
  • Field undonextLSN
  • LSN from prevLSN of correspondent Update log
    record

11
The Write-Ahead Log Protocol
  • All Update log records must be written to stable
    storage first
  • Log records
  • Transaction records
  • Systems records

12
Checkpoints
  • A point of synchronization between database and
    transaction log
  • All buffers are force-written to secondary
    storage
  • Checkpoints in AREIS
  • Begin_checkpoint record
  • End_checkpoint record
  • Master record holds LSN of the begin_checkpoint
    record

13
Recovery Using Deferred Update
  • Updates are not written to the database until the
    transaction T commits
  • T starts
  • Start log record
  • T commits
  • Commit log record
  • Log tail is force-written to disk
  • Updates are implemented

14
Recovery Using Deferred Update (cont)
  • T aborts
  • Abort log record
  • Ignore the log records related to T
  • Recovery after the crash
  • Most recent checkpoint
  • Transactions with Start and Commit log records
    are redone
  • Transactions with Start and Abort log records are
    ignored
  • Transactions that have neither Commit nor Abort
    log records receive Abort log records

15
Recovery Using Immediate Update
  • Updates are written to the database as they occur
  • T starts
  • Start log record
  • T writes
  • Update log record
  • Update is written to the buffer
  • Update is applied to the database when the buffer
    content is transferred to secondary storage
  • T commits
  • Commit log record

16
Recovery Using Immediate Update (cont)
  • T aborts
  • Updates are undone in reverse order
  • Recovery after the crash
  • Most recent checkpoint
  • Transactions with Start and Commit log records
    are redone
  • Transactions with Start log record that dont
    have Commit log record are undone

17
Recovery (Example 10)
T1
T2
T3
T4
T5
T6
tc
tf
18
ARIES
  • Algorithm for Recovery and Isolation Exploiting
    Semantics
  • Works with steal, no-force policies
  • Three main phases
  • Analysis
  • Redo
  • Undo

19
Basic Principles
  • Write-ahead logging
  • Repeating history during Redo phase
  • Logging of all changes during Undo phase

20
Analysis Phase
  • Scan log from the checkpoint to the end
  • Main goal
  • To determine the point in the log at which to
    start the Redo step
  • To determine dirty pages at the moment of the
    crash
  • To identify active transactions at the time of
    the crash

21
Analysis Step Result
  • Transaction Table contains accurate list of
    transactions active at the moment of the crash
  • (actions must be undone)
  • Dirty Page Table contains list of modified pages
    that must be recorded to secondary storage
  • (actions must be redone)

22
Redo Phase
  • Repeating history paradigm
  • Redo(Redo(A)) Redo(A)
  • Redo actions are recorded to the log
  • The result
  • The database is brought to the state as before
    the crash

23
Undo Phase
  • Scans backward from the end of the log
  • Undo(Undo(A)) Undo(A)
  • For every Undo action the CLR is added to the log
  • Removes all changes caused by incomplete
    transactions
Write a Comment
User Comments (0)
About PowerShow.com