Rollback and recovery gate question


#1

Question 1 : 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?

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


#2

In order to answer this question, you must know what exactly happens when a system with concurrent transactions crashes and recovers.
So, whenever a system crash occurs , the recovery system plays a major role. It reads the logs backwards from the end to the last checkpoint. It maintains two lists, an undo-list and a redo-list.
If the recovery system sees a log with and or just , it puts the transaction in the redo-list.
If the recovery system sees a log with but no commit or abort log found, it puts the transaction in undo-list.

All the transactions in the undo-list are then undone and their logs are removed. All the transactions in the redo-list and their previous logs are removed and then redone before saving their logs.
So Answer is B redo log records 2 and 3 and undo log record 6 .


#3

Answer:(B)

Explanation : we must undergo log record 6 to set B to 10000 and then redo log records 2 and 3 because system faols before commit operation.so we need to undone active transactions(T2) and redo committed transactions(T1)

note: here we are not using checkpoints.

Recovery :
when a system with concurrent transactions crashes and recovers,it behaves in the following manner–

–> The recovery system reads the logs backwards from the end to last checkpoint.
–> It maintains two lists, an undo -list ,redo-list.
–> If the recovery system sees a log with but no commit or abort log found,it puts the transaction in undo-list.
–>All the transactions in the undo list are then undone and their logs are removed.All the transactions in the redo-list and their previous logs are removed and then redone before saving their logs.

so the answer is B redo log records 2 and 3 and undo log record 6.