Differentiate between Immediate and Deferred Log-based recovery methods.…
2025
Differentiate between Immediate and Deferred Log-based recovery methods. Generate the log file of below given (Figure 1) transaction using both Immediate and Deferred recovery methods. Also state, if the failure happens in T1 before commit, what will happen in both Immediate and Deferred recovery methods? In Figure 2, which one of the two Log-based recovery methods (Immediate or Deferred) is used to generate the file? If crash happens now (after T3 is written to file), and system tries to recover both undo and redo operations also, which transaction will go to each of undo and redo list?

Attempted by 4 students.
Show answer & explanation
Difference between Immediate and Deferred Log-based Recovery
In deferred update recovery method, the database is not updated until the transaction commits. All updates are first recorded in the log and applied to the database only after the commit operation. Therefore, during recovery only redo operations are required because uncommitted transactions never modify the database.
In immediate update recovery method, updates are written to the database before the transaction commits. The log records contain both old and new values of the data item. Therefore during recovery the system may need both undo operations (for uncommitted transactions) and redo operations (for committed transactions).
Log file generation for Transaction T1
Transaction T1 operations
R(A)
A = A − 100
W(A)
R(B)
B = B + 200
W(B)
Commit
Immediate update log
<T1 Start> <T1, A, oldA, newA> <T1, B, oldB, newB> <T1 Commit>
Deferred update log
<T1 Start> <T1, A, newA> <T1, B, newB> <T1 Commit>
If failure occurs before T1 commit
Immediate recovery
Since updates may already be written to disk, the system performs undo to restore original values.
Deferred recovery
No action is required because the database was not updated before commit.
Identify recovery method used in Figure 2
Log entries such as
<T4, Y, 2, 3>
<T1, Z, 5, 7>
contain both old and new values. This indicates the Immediate update recovery method.
Determine undo and redo lists after crash
Log records in Figure 2
<T4 Start> <T4, Y, 2, 3> <T1 Start> <T4 Commit> <T1, Z, 5, 7> Checkpoint <T2 Start> <T2, X, 1, 9> <T2 Commit> <T3 Start> <T3, Z, 7, 2>
Committed transactions
T4 and T2
Uncommitted transactions
T1 and T3
Redo list
T4, T2
Undo list
T1, T3
During recovery the system will redo updates of T4 and T2 and undo the updates of T1 and T3 to maintain database consistency.