Demonstrate the System Log in database transaction

Demonstrate the System Log in database transaction

Answer:-

System Log in Database Transactions

A system log is an essential part of DBMS transaction management. It keeps track of all operations performed during transactions, allowing the system to recover from failures and ensure ACID properties, especially atomicity and durability.


Purpose of the System Log

  • Records all changes made during transactions
  • Helps recover the database to a consistent state after crashes
  • Supports rollback (undo) and redo operations

Types of Information in a Log Record

A typical log record contains:

  • Transaction ID
  • Type of operation (e.g., WRITE, COMMIT, ABORT)
  • Data item affected
  • Old value (before the change)
  • New value (after the change)
  • Timestamp

Types of Log Entries

Log EntryDescription
STARTIndicates the beginning of a transaction
WRITELogs changes: the old and new value of data
COMMITIndicates successful completion of a transaction
ABORT/ROLLBACKMarks the cancellation of a transaction
CHECKPOINTMarks a save point to simplify recovery

Example Log for a Transaction T1

Assume T1 updates Account A from ₹500 to ₹400.

[START, T1]
[WRITE, T1, A, 500, 400]
[COMMIT, T1]

Explanation:

  • The transaction T1 begins
  • It changes the value of A from 500 to 400
  • It commits, making the change permanent

Crash and Recovery Scenario

If the system crashes after the WRITE but before COMMIT, the log will contain:

[START, T1]
[WRITE, T1, A, 500, 400]
-- Crash
  • Since COMMIT is missing, T1 must be rolled back
  • Value of A is restored to 500

If COMMIT was written before the crash, then redo is applied to ensure the update persists.


Checkpointing

  • The DBMS periodically writes a checkpoint to the log like:
[CHECKPOINT, T1, T2]
  • This reduces the recovery time by limiting how far back the system needs to look.

Summary Table

ComponentFunction
STARTBegin transaction
WRITERecord old and new values of an update
COMMITConfirm transaction success and durability
ABORT/ROLLBACKCancel a transaction and restore original values
CHECKPOINTEstablish a recovery snapshot for active transactions

Leave a Reply

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