Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
Log Based Recovery in Databases

Log Based Recovery in Databases

Posted on September 7, 2025September 7, 2025 By Rishabh saini No Comments on Log Based Recovery in Databases

Log Based Recovery in Databases

In database management systems, log-based recovery is a fundamental technique used to maintain the consistency of the database in case of failures. A log is a series of documents kept for each transaction in a stable location. After any unanticipated failures, these logs guarantee that the system can recover and return the database to a consistent condition.

Every time a transaction makes a change to the database, it is noted in the log. Importantly, these logs must be written before the actual changes are applied to the database to ensure reliable recovery.

Consider an example where a transaction modifies a student’s city from “Noida” to “Bangalore.” The log entries for this transaction would be as follows:

  • When the transaction starts:
    <Tn, Start>
  • When the city is updated:
    <Tn, City, 'Noida', 'Bangalore'>
  • When the transaction commits:
    <Tn, Commit>

This logging ensures that even if the system crashes, all operations can be traced and recovered.

Machine Learning Tutorial:–Click Here
Data Science Tutorial:-Click Here
Complete Advance AI topics:- CLICK HERE
Deep Learning Tutorial:- Click Here

Approaches to Database Modification

1. Deferred Database Modification

The database is updated only after the transaction has committed when using the deferred modification technique. Up until that point, every modification is noted in the log but isn’t applied to the database. This technique simplifies recovery, especially in a single-user environment.

Recovery Steps in Deferred Update

  1. Find the log’s most recent checkpoint. The database already contains the transactions that were committed before to this checkpoint.
  2. After the last checkpoint, rerun the transaction using the log’s changes for any transactions that have both [Start_transaction, T] and [Commit, T].
  3. Since their modifications were never implemented, transactions that include only a [Start_transaction, T] record and no [Commit, T] call for no action.

Example

Consider two transactions:

  • T1: Transfers Rs. 200 from account A to B.
  • T2: Withdraws Rs. 100 from account C.

Initial balances:

  • A = 1000, B = 1500, C = 2000

Logs during execution:

Log EntryDatabase Action
[Start_transaction, T1]–
[Write, T1, A, 800]Not applied yet
[Write, T1, B, 1700]Not applied yet
[Commit, T1]Apply T1: A = 800, B = 1700
[Start_transaction, T2]–
[Write, T2, C, 1900]Not applied yet
[Commit, T2]Apply T2: C = 1900

In case of a system crash:

  • Transactions with commit records are redone.
  • Transactions without commit records are ignored.

This ensures data consistency while avoiding partial updates.

2. Immediate Database Modification

The immediate modification approach updates the database as the transaction executes, rather than waiting for commit. This method uses write-ahead logging (WAL) to record changes before applying them, ensuring recovery is possible even if a crash occurs.

Recovery Techniques

  1. Undo/No Redo: Transactions that fail before committing are rolled back; no redo is needed since changes are only applied after commit.
  2. Undo/Redo: Changes may be applied before commit. Transactions that fail before committing are undone, and committed transactions are redone from the log.

Recovery Steps in Immediate Update

  1. Find the latest checkpoint in the log. Transactions committed before this checkpoint need no action.
  2. Transactions with both [Start_transaction, T] and [Commit, T] are redone.
  3. Transactions with [Start_transaction, T] but no [Commit, T] are undone, applying old values in reverse order for multiple writes.

Example

Using the same transactions T1 and T2:

Log EntryDatabase Action
[Start_transaction, T1]Begin T1
[Write, T1, A, 1000, 800]A updated to 800 immediately
[Write, T1, B, 1500, 1700]B updated to 1700 immediately
[Commit, T1]Transaction committed
[Start_transaction, T2]Begin T2
[Write, T2, C, 2000, 1900]C updated to 1900 immediately
[Commit, T2]Transaction committed

In case of a crash:

  • Transactions without a commit are undone.
  • Transactions with a commit are redone if necessary.

Multiuser Environment

In a multiuser setting, immediate updates require careful handling of deadlocks. Uncommitted transactions must be rolled back to maintain consistency, while committed transactions are redone if the system crashes.

Complete Python Course with Advance topics:-Click Here
SQL Tutorial :–Click Here

Download New Real Time Projects :–Click here

Key Rules for Log-Based Recovery

  1. If the log contains <Ti, Start> and <Ti, Commit>, the transaction needs to be redone.
  2. If the log contains <Ti, Start> but no <Ti, Commit> or <Ti, Abort>, the transaction needs to be undone.

By following these principles, log-based recovery ensures reliable and consistent recovery, regardless of whether the database uses deferred or immediate modification techniques.

Log-based recovery remains a cornerstone of database reliability, offering systematic strategies to handle failures while safeguarding data integrity. Whether using deferred updates for simplicity or immediate updates for efficiency, the log is always the ultimate source of truth.


types of log-based recovery in dbms
log-based recovery example
recovery techniques in dbms
recovery with concurrent transaction in dbms
shadow paging in dbms
checkpoint recovery in dbms
recovery and atomicity in dbms
advantages of log based recovery in dbms
log-based recovery example
types of log-based recovery in dbms
log-based recovery in distributed system
log-based recovery in dbms ppt
difference between log-based recovery and shadow paging
log based recovery in dbms in hindi
log based recovery in dbms geeksforgeeks
checkpoint recovery in dbms
log based recovery example
log based recovery dbms
log based recovery dbms example

    Post Views: 282
    DBMS Tutorial Tags:backup and recovery, crash recovery, database recovery, dr mike recovery, lock based recovery in dbms, log based database recovery, log based recovery, log based recovery and shadow paging, log based recovery in databse, log based recovery in dbms, log based recovery in telugu, log based recovery lectures, log based recovery techniques in dbms, log based recovery tutorials, log based recovery video lectures, log based recovery video tutorials, log-based recovery, recovery, recovery jb, recovery of database

    Post navigation

    Previous Post: Best AI powered Fake News Detection
    Next Post: Best Farm Management System Project Using Python – Complete Guide

    More Related Articles

    What is a Database What is a Database? Definition, Types, Examples DBMS Tutorial
    Data Model Data Model: Schema and Instance DBMS Tutorial
    Rule of inference Understanding Rule of inference in Functional Dependency – A Guide by UpdateGadh DBMS Tutorial

    Leave a Reply Cancel reply

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

    Most Viewed Posts

    1. Top Large Language Models in 2025
    2. Online Shopping System using PHP, MySQL with Free Source Code
    3. login form in php and mysql , Step-by-Step with Free Source Code
    4. Flipkart Clone using PHP And MYSQL Free Source Code
    5. News Portal Project in PHP and MySql Free Source Code
    6. User Login & Registration System Using PHP and MySQL Free Code
    7. Top 10 Final Year Project Ideas in Python
    8. Online Bike Rental Management System Using PHP and MySQL
    9. E learning Website in php with Free source code
    10. E-Commerce Website Project in Java Servlets (JSP)
    • AI
    • ASP.NET
    • Blockchain
    • ChatCPT
    • code Snippets
    • Collage Projects
    • Data Science Project
    • Data Science Tutorial
    • DBMS Tutorial
    • Deep Learning Tutorial
    • Final Year Projects
    • Free Projects
    • How to
    • html
    • Interview Question
    • Java Notes
    • Java Project
    • Java Script Notes
    • JAVASCRIPT
    • Javascript Project
    • JSP JAVA(J2EE)
    • Machine Learning Project
    • Machine Learning Tutorial
    • MySQL Tutorial
    • Node.js Tutorial
    • PHP Project
    • Portfolio
    • Python
    • Python Interview Question
    • Python Projects
    • PythonFreeProject
    • React Free Project
    • React Projects
    • Spring boot
    • SQL Tutorial
    • TOP 10
    • Uncategorized
    • Online Examination System in PHP with Source Code
    • AI Chatbot for College and Hospital
    • Job Portal Web Application in PHP MySQL
    • Online Tutorial Portal Site in PHP MySQL — Full Project with Source Code
    • Online Job Portal System in JSP Servlet MySQL

    Copyright © 2026 UpdateGadh.

    Powered by PressBook Green WordPress theme