Domanda

When do we use undo and redo operations in a Database recovery ? For instance consider the following questions asked in an exam (not a homework)

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 all transactions undergo undo and redo operations ?

All i know here is that if the system crashes right after the commit is written to the log and before flushing the buffer to a secondary storage, we need to redo those transactions. But here the system crashes before writing the log entry for commit. So if we undo records 2 and 3, will it be enough ?

È stato utile?

Soluzione

If the database crashes at point 7, everything until point 4 (including) is already on disk. That is the guarantee that commit gives (assuming no special features like async commit are used).

During recovery basically the state after point 4 is restored.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top