BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Log-Based Recovery in DBMS

Last Updated: July 4, 2022 by Chaitanya Singh | Filed Under: DBMS

In the previous chapters, you learned how to identify a recoverable schedule and what kind of failures can occur in DBMS. In this chapter, you will learn how to recover a failed transaction using Log-based recovery in DBMS. When a transaction fails, it is important to rollback the transaction so that changes made by failed transaction doesn’t store in the database, this is important to maintain the integrity of database.

What is log-based recovery in DBMS?

  1. As the name suggests, log is a sequence of records that is maintained in a stable storage devices to note down all the changes made by transactions in a sequential manner. This log is used to recover the transaction in case of failure.
  2. Any operation performed by transaction on database is recorded in the log.
  3. It is important to record the log before the actual operation performed on the database, this make sure that if an operation fail, it is already recorded in the log.

How the logs are maintained?

Let’s take an example to understand the log-based recovery in DBMS:

A transaction T1 is modifying the Department of an employee, for this operation, the following log is maintained:

Log entry to mark the start of the transaction:

<T1, Start>

Just before the transaction modifies the department of the employee from “Sales” To “Marketing”, the following log is maintained:

<T1, Department, 'Sales', 'Marketing' >  

Log entry to mark the successful end of the transaction:

<T1, Commit>

Logs for different database modification approaches

There are two database modification approaches used by the transactions. Here we will learn how the logs are maintained for each approach:

1. Deferred Database Modification

In this approach, the transaction does not commit the changes the database, until it is completed successfully.

In this approach, all the logs are created at once and stored in the database.

2. Immediate Database Modification

In this approach, the transaction make change immediately after an operation is performed by the transaction.

In this approach, logs are recorded just before the transaction is going to perform an operation in database.

Recovery using Log Records

In case of a transaction failure, the log is referenced to recover the transaction and rollback or redone all the changes done by the transaction.

  • If the log contains the entry <Tn, Start> and <Tn, Commit> or <Tn, Start> and <Tn, Abort> then the transaction Tn needs to be redone based on the log entries for each operation recorded in the log.
  • If the log contains the entry <Tn, Start> but doesn’t contain an entry for <Tn, Commit> or <Tn, Abort> then the transaction needs to be rolled back.
❮ Failure ClassificationCheckpoint in DBMS ❯

Top Related Articles:

  1. Failure Classification in DBMS
  2. DBMS Transaction States
  3. Transaction Management in DBMS
  4. Cardinality in DBMS
  5. Types of DBMS (Database Management System)

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

DBMS Tutorial

Basics

  • DBMS Tutorial
  • DBMS Introduction
  • Database Applications
  • DBMS vs File System
  • DBMS vs RDBMS
  • DBMS Architecture
  • Three-level DBMS architecture
  • View in DBMS
  • Abstraction
  • Instance & Schema
  • DBMS languages

Data Models

  • Data Models
  • ER Diagram
  • ER Design issues
  • Convert ER to table
  • DBMS Generalization
  • DBMS Specialization
  • DBMS Aggregration
  • Relational Model
  • Hierarchical Model
  • Constraints
  • Cardinality

Relational Database

  • RDBMS concepts
  • Relational Algebra
  • Relational Calculus
  • Keys Index
  • Primary Key
  • Super Key
  • Candidate Key
  • Foreign Key
  • Composite Key
  • Alternate Key

Normalization

  • Normalization
  • Functional dependency

Transaction Management

  • Transaction Management
  • ACID properties
  • Transaction States
  • DBMS Schedules
  • Serializability
  • Conflict Serializability
  • View Serializability
  • Recoverability Of Schedule
  • Failure Classification
  • Log based Recovery
  • DBMS Checkpoint
  • Deadlock

Concurrency Control

  • Concurrency Control
  • Lock based protocol
  • Timestamp based protocol
  • Validation based protocol

File Organization

  • File Organization
  • Sequential File Organization
  • Heap File Organization
  • Hash File Organization
  • DBMS ISAM
  • B+ File Organization
  • Cluster File Organization

SQL Introduction

  • SQL Introduction
  • SQL Characteristics
  • Advantages of SQL
  • SQL Commands
  • SQL Operators
  • SQL CREATE
  • SQL DROP
  • SQL SELECT
  • SQL INSERT

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap