Consider the following log sequence of two transactions on a bank account,…

2006

Consider the following log sequence of two transactions on a bank account, with initial balance 12000, that transfer 2000 to a mortgage payment and then apply a 5% interest.

  1. T1 start
  2. T1 B old=12000 new=10000
  3. T1 M old=0 new=2000
  4. T1 commit
  5. T2 start
  6. T2 B old=10000 new=10500
  7. T2 commit 

Suppose the database system crashes just before log record 7 is written. When the system is restarted, which one statement is true of the recovery procedure?

Answer: B. We must undo log record 6 to set B to 10000 and then redo log records 2 and 3.When the system crashes before log record 7 (T2 commit), the recovery procedure must ensure database consistency. T1 has committed (log records 1–4), so its…

  1. A.

    We must redo log record 6 to set B to 10500

  2. B.

    We must undo log record 6 to set B to 10000 and then redo log records 2 and 3.

  3. C.

    We need not redo log records 2 and 3 because transaction T1 has committed.

  4. D.

    We can apply redo and undo operations in arbitrary order because they are idempotent

Attempted by 16 students.

Show answer & explanation

Correct answer: B

When the system crashes before log record 7 (T2 commit), the recovery procedure must ensure database consistency. T1 has committed (log records 1–4), so its changes (B from 12000 to 10000, M from 0 to 2000) are durable and do not need redo. T2 has started (record 5) and modified B to 10500 (record 6), but it did not commit. Therefore, T2's changes must be undone to restore B to 10000. The recovery process involves: 1) Undoing T2's update to B, 2) Redoing T1's changes to ensure the transfer is applied. The order is critical: undo must precede redo.

Explore the full course: Wipro Preparation

Loading lesson…