ADSI Notes - Diogo Lopes

Search

Search IconIcon to open search

Lecture 8 - Database Recovery

Last updated Mar 20, 2023

Slides

# Database Crash and Recovery System

# Failure Classification

# Transaction failure

# System crash

A power failure or other hardware or software failure causes the system to crash.

# Disk failure

A head crash or similar disk failure destroys all or part of disk storage

# Stable Storage

See: Volatile and Non-Volatile Storage

An ideal form of storage that survives all failures

Log example:

  1. We ask the OS to write the object and take note in the log of the change in the object
    • In case of sys failure and are not sure if the change in disk we can check the log in case we need to replicate the change
  2. The OS doesnt execute the operation right away
  3. It outputs objects in diff order of the transactions

# CRASH

If crash after commits - no problem in reapplying the changes

# REDO

# UNDO

See Slides for examples (18)

# Checkpoints

Recovery after system failure:

Example not in image:

# Recovery Algorithm

REDO phase

  1. Find last < checkpoint L > record, and set undo list to L
  2. Scan forward from above < checkpoint L > record
    1. Whenever a record < Ti Xj , V1 , V2> or <Ti , Xj , V2> is found, REDO it by writing V2 to Xj
    2. Whenever a log record < Ti > start is found, add < Ti > to undo list
    3. Whenever a log record < Ti commit > or < Ti abort > is found, remove Ti from undo list

UNDO phase:

  1. Scan log backwards from end
  2. Whenever a log record < Ti Xj V1 , V2 > is found where Ti is in UNDO list perform the following rollback actions:
    1. perform UNDO by writing V1 to Xj
    2. write a CLR
  3. Whenever a log record Ti start is found where Ti is in UNDO list,
    1. Write a log record < Ti abort >
    2. Remove Ti from UNDO list
  4. Stop when UNDO list is empty
    1. i.e. < Ti start > has been found for every transaction in UNDO list

After undo phase completes, normal transaction processing can commence

# ARIES

Algorithm for Recovery and Isolation Exploiting

In ARIES,

Besides the log, ARIES RECONSTRUCTS the two additional data structures

# Recovery in ARIES

SQL Server uses.

  1. Analysis - Reconstruct dirty page table and active transaction table
  2. Redo - Repeats all actions, starting from an appropriate checkpoint in the log (first entry in DIRTY PAGES TABLE), and restores the database state to what it was at the time of the crash (re-writes).
  3. Undo - Undoes the actions of transactions that did not commit (TRANSACTION TABLE), so that the database reflects only the actions of committed transactions.
  4. CLRs are to be redone, never to be undone

See Slides for examples (38~44) Note:

ARIES uses a log-based approach to recover from failures. It maintains a write-ahead log (WAL) that records all updates made by transactions before they are written to the database.

The distinction between end and commit is unclear (couldn’t get a clear answer from Chat-GPT)

Lecture 7 Transactions and concurrency pt2 | Lecture 9 Tuning