Database Recovery Concepts

 

Database Recovery Concepts

1. Introduction

Database recovery refers to the process of restoring the database to a consistent state after a failure such as system crashes, transaction errors, or disk failures.

The main objectives of recovery are:

  • Atomicity – Incomplete transactions must be undone.

  • Durability – Committed transactions must remain permanent.

To support recovery, the DBMS maintains a system log that records all updates performed by transactions.


2. Types of Failures

Database failures are classified into two types:

1. Catastrophic Failure

These failures cause physical damage to the database.

Examples:

  • Disk crash

  • Hardware failure

Recovery method:

  • Restore database from backup

  • Redo committed transactions using the log.


2. Non-Catastrophic Failure

These failures do not damage the database physically.

Examples:

  • System crash

  • Transaction abort

  • Software errors

Recovery is done using log records.


3. Recovery Algorithms

There are two main recovery techniques.

TechniqueDescription
Deferred UpdateDatabase updated only after transaction commits
Immediate UpdateDatabase updated before commit

4. Deferred Update (NO-UNDO / REDO)

In deferred update, the database is not updated until the transaction commits.

  • Updates are stored in buffers or logs.

  • If transaction fails → no undo required.

  • If system crashes after commit → redo operations are required.

Thus it is called:

NO-UNDO / REDO

5. Immediate Update

In immediate update, the database may be updated before the transaction commits.

If a transaction fails:

  • Changes already written to disk must be undone.

Recovery may require:

  • Undo of uncommitted transactions

  • Redo of committed transactions

Two variations exist:

AlgorithmDescription
UNDO/REDO        Both undo and redo required
UNDO/NO-REDO        Only undo required

6. Write-Ahead Logging (WAL)

Write-Ahead Logging ensures that log records are written to disk before database updates.

Rules of WAL:

  1. Before a data item is updated, its before image must be written to the log.

  2. A transaction cannot commit until all its log records are written to disk.

This guarantees correct recovery.


7. Buffer Management

DBMS uses main memory buffers (cache) to store disk pages temporarily.

Important components:

Dirty Bit

  • Indicates whether a page has been modified.

ValueMeaning
0        Not modified
1    Modified

Pin/Unpin Bit

  • Determines whether a page can be written back to disk.


8. Steal / No-Steal and Force / No-Force Policies

Steal / No-Steal

PolicyMeaning
No-Steal            Updated pages cannot be written before commit
Steal            Updated pages may be written before commit

Force / No-Force

PolicyMeaning
Force        All updates written to disk before commit
No-Force        Updates may remain in memory

Most DBMS use:

Steal + No-Force

Which requires UNDO and REDO operations.


9. Checkpoints

A checkpoint is a special log record that indicates that all modified buffers have been written to disk.

Format:

[checkpoint, list of active transactions]

Purpose:

  • Reduces recovery time

  • During crash recovery, the system only examines log records after the last checkpoint.


10. Fuzzy Checkpointing

Normal checkpointing pauses transaction processing.

To avoid delays, fuzzy checkpointing is used.

Steps:

  1. Write begin_checkpoint record

  2. Continue transaction execution

  3. Flush buffers gradually

  4. Write end_checkpoint


11. Transaction Rollback

If a transaction fails before commit, the system performs rollback.

Rollback process:

  • Use log records

  • Restore before images (BFIM) of data items

  • Undo all write operations.


12. Cascading Rollback

Cascading rollback occurs when one transaction depends on another.

Example:

  • T1 writes a value

  • T2 reads that value

  • If T1 aborts → T2 must also abort.

To avoid cascading rollback, DBMS uses strict or cascadeless schedules.


Conclusion

Database recovery techniques ensure that the database remains consistent and reliable after failures.
Key components of recovery include:

  • Log files

  • Write-Ahead Logging

  • Checkpoints

  • Undo and Redo operations

Modern DBMS typically use steal/no-force strategy with WAL, which supports efficient recovery.

Comments

Popular posts from this blog

Database Management Systems DBMS PCCST402 Semester 4 KTU CS 2024 Scheme

Data Models, Schemas and Instances

Introduction to Database Management System -DBMS