Hi All,
I am somewhat confused with the transaction recovery during a system crash.
I read that a Redo operation will be performed during a crash recovery when
The LSN of transaction log record is greater than that of the LSN of data page that log belongs
And Undo operation will be performed when
The LSN of Transaction log record is equal to or less than the LSN of data page that log belongs.
Now here is where I am confused.
1. If two transactions are happening on two pages as below after a checkpoint before a system crashed.
a. Transaction 1-- which got committed before system crashed (roll forward).
b. Transaction 2 -- Still in progress and got terminated because of system crashed and not committed (this means it has to be roll backed).
Now my question is when the Transaction 1 got committed, all the log records related to Transaction 1 (committed) and Transaction 2 (uncommitted) will be forced written to disk (I’ve also read this statement in one book)? Or only the Transaction 1 log records are forced written to disk?
In case, If all the transactions (both committed and uncommitted) are forced written to disk, and when during the crash recovery happens, obliviously the LSN’s in transaction log records for Transaction 1&2 are greater than the LSN’s of data pages and this means it will redo the operation for Transaction 2?
And last… how many LSN’s will be given when a transaction is executed as below explicitly
Begin tran
Delete