Open In App

ISRO | ISRO CS 2015 | Question 17

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=1200 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?

(A)



We must redo log record 6 to set B to 10500

(B)



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

(C)

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

(D)

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


Answer: (B)
Explanation:

Explanation:

Based on the provided log sequence, the correct answer is:

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

The recovery procedure, in this case, involves undoing and redoing certain log records to restore the database to a consistent state. Here’s a step-by-step explanation:

  1. The system crashed just before log record 7 was written, which means transaction T2 did not complete and needs to be rolled back.
  2. To undo the changes made by T2, we need to reverse the effects of log record 6, which set B to 10500. We must undo this operation and set B back to its original value of 10000.
  3. Once the undo operation is complete, we need to redo log records 2 and 3. These records represent the changes made by T1, which transferred 2000 to a mortgage payment. By redoing these records, we ensure that the effect of T1’s committed transaction is reapplied to the database.

By following this process of undoing the incomplete transaction (T2) and redoing the committed transaction (T1), we can bring the database back to a consistent state after the crash.

Option (A) is incorrect because log record 6, which was part of the incomplete transaction T2, needs to be undone, not redone.

Option (C) is incorrect because even though T1 has committed, its changes (log records 2 and 3) still need to be reapplied during the recovery process.

Option (D) is incorrect because the redo and undo operations should be performed in the specified order, as outlined in the explanation above. The order of operations is crucial for correctly restoring the database to a consistent state.

Quiz of this Question

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :