patternMinor
Understanding Transaction Recovery
Viewed 0 times
understandingrecoverytransaction
Problem
In the following reference, there is an algorithm outlining a transaction recovery algorithm using redo and undo. The algorithm is as follows:
It then gives the example:
but this is clearly wrong?? Since T2 has been committed, T must be in the REDO list. Am I missing something?
UNDO and REDO: lists of transactions
UNDO = all transactions running at the last checkpoint
REDO = empty
For each entry in the log, starting at the last checkpoint
If a BEGIN TRANSACTION entry is found for T
Add T to UNDO
If a COMMIT entry is found for T
Move T from UNDO to REDOIt then gives the example:
but this is clearly wrong?? Since T2 has been committed, T must be in the REDO list. Am I missing something?
Solution
If you look throught the slides from beginning to end you will find that the explanation is pretty accurate.
The depicted slide is showing you the situation as it is at the time when the vertical axis is at the checkpoint.
-
At that time T2 and T3 are put into the UNDO queue.
-
Moving forward (in the reference) the examined time (vertical axis) moves forward and reaches the BEGIN of T4. The transaction T4 is put into the UNDO queue.
-
Moving forward (in the reference) the examined time (vertical axis) moves forward and reaches the BEGIN of T5. The transaction T5 is put into the UNDO queue.
You now have all four transactions T1, T2, T3, T4 in the UNDO queue.
-
Moving further forward (in the reference) the examined time (vertical axis) moves forward and reaches the END of T2. The transaction T2 is put into the REDO queue.
-
Moving forward (in the reference) the examined time (vertical axis) moves forward and reaches the END of T4. The transaction T4 is put into the REDO queue.
The transactions T3 and T5 are in the UNDO queue.
The transactions T2 and T4 are in the REDO queue.
Moving even further forward (in the reference) the examined time (vertical axis) moves forward and reaches the Failure.
T3 and T5 are UNDO-ne and T2 and T4 are REDO-ne (or reapplied).
The database is now in a consistent state.
- The recovery of the database starts.
The depicted slide is showing you the situation as it is at the time when the vertical axis is at the checkpoint.
-
At that time T2 and T3 are put into the UNDO queue.
-
Moving forward (in the reference) the examined time (vertical axis) moves forward and reaches the BEGIN of T4. The transaction T4 is put into the UNDO queue.
-
Moving forward (in the reference) the examined time (vertical axis) moves forward and reaches the BEGIN of T5. The transaction T5 is put into the UNDO queue.
You now have all four transactions T1, T2, T3, T4 in the UNDO queue.
-
Moving further forward (in the reference) the examined time (vertical axis) moves forward and reaches the END of T2. The transaction T2 is put into the REDO queue.
-
Moving forward (in the reference) the examined time (vertical axis) moves forward and reaches the END of T4. The transaction T4 is put into the REDO queue.
The transactions T3 and T5 are in the UNDO queue.
The transactions T2 and T4 are in the REDO queue.
Moving even further forward (in the reference) the examined time (vertical axis) moves forward and reaches the Failure.
T3 and T5 are UNDO-ne and T2 and T4 are REDO-ne (or reapplied).
The database is now in a consistent state.
Context
StackExchange Database Administrators Q#172122, answer score: 3
Revisions (0)
No revisions yet.