Skip to main content

Recovery from log: deferred vs immediate

Short answer

Under deferred modification, redo T0 (A=950, B=2050) and no action for T1. Under immediate modification, redo T0 (A=950, B=2050) and undo T1 (restore C to 700).

Consider the following log at the time of a crash. Deferred modification: <T0 start>, <T0, A, 950>, <T0, B, 2050>, <T0 commit>, <T1 start>, <T1, C, 600> Immediate modification: <T0 start>, <T0, A, 1000, 950>, <T0, B, 2000, 2050>, <T0 commit>, <T1 start>, <T1, C, 700, 600> State the recovery actions (redo/undo) required for each transaction under both schemes.

After a crash the system scans the log. A transaction with both <T start> and <T commit> is redone; a transaction with <T start> but no <T commit> is incomplete.

Deferred modification

In deferred modification, writes to the database are postponed until the transaction commits. The log record <T, X, new> holds only the new value.

Log: <T0 start>, <T0, A, 950>, <T0, B, 2050>, <T0 commit>, <T1 start>, <T1, C, 600>

TransactionLog statusAction
T0start and commitredo(T0): set A = 950, B = 2050
T1start, no commitnothing (no undo needed)

T1 had not committed, so none of its writes had reached the database; its log records are simply ignored and C keeps its old value. No undo is needed in deferred modification. Redo is idempotent, so repeating it is safe.

Immediate modification

In immediate modification, updates may reach the database before commit. The log record <T, X, old, new> holds both values.

Log: <T0 start>, <T0, A, 1000, 950>, <T0, B, 2000, 2050>, <T0 commit>, <T1 start>, <T1, C, 700, 600>

TransactionLog statusAction
T0start and commitredo(T0): set A = 950, B = 2050 (new values)
T1start, no commitundo(T1): set C = 700 (old value); write <T1 abort>

Order of recovery: in the classic scheme the undo pass scans the log backward and restores the old values of incomplete transactions (C = 700), and then the redo pass scans forward and reapplies the committed ones (A = 950, B = 2050). The newer "repeating history" algorithm does the redo pass first and then the undo pass. Here T0 and T1 touch different items, so both orders give the same result.

Final state after recovery

  • A = 950, B = 2050 (T0 committed)
  • C = 700 (T1's change removed)
SchemeRedoUndo
DeferredT0none
ImmediateT0T1

✓ Answer checked by Claude Opus 5.5 (high effort)

All Database Management System chapter 8 questions →