- Suppose the
system
crashes after writing
one of the 2 <COMMIT> records:
Undo/redo log:
<START T1>
<T1, A, 4, 5>
<START T2>
<COMMIT T1> ==== T1 done
<T2, B, 9, 10>
============================
<START CKPT(T2)>
<T2, C, 14, 15> <--+ Between here:
<START T3> | **** OUTPUT(A) and OUTPUT(B)
<T3, D, 19, 20> <--+
<END CKPT> // Flush Log
<COMMIT T2> ===== T2 done
+++++++++++++++++++++++++++++++++++++++ System crashed....
<COMMIT T3> ===== T3 done
(OUTPUT for T2 and T3 happens later)
|
- We scan backwards and
finds the
<END CKPT> record
first:
Undo/redo log:
<START T1>
<T1, A, 4, 5>
<START T2>
<COMMIT T1> ==== T1 done
<T2, B, 9, 10>
============================
<START CKPT(T2)>
<T2, C, 14, 15> <--+ Between here:
<START T3> | **** OUTPUT(A) and OUTPUT(B)
<T3, D, 19, 20> <--+
<END CKPT> // Flush Log
<COMMIT T2> ===== T2 done
+++++++++++++++++++++++++++++++++++++++ System crashed....
<COMMIT T3> ===== T3 done
(OUTPUT for T2 and T3 happens later)
|
- Scan further and
find <START CKPT> record:
Undo/redo log:
<START T1>
<T1, A, 4, 5>
<START T2>
<COMMIT T1> ==== T1 done
<T2, B, 9, 10>
============================
<START CKPT(T2)>
<T2, C, 14, 15> <--+ Between here:
<START T3> | **** OUTPUT(A) and OUTPUT(B)
<T3, D, 19, 20> <--+
<END CKPT> // Flush Log
<COMMIT T2> ===== T2 done
+++++++++++++++++++++++++++++++++++++++ System crashed....
<COMMIT T3> ===== T3 done
(OUTPUT for T2 and T3 happens later)
|
Conclusion:
- Committed:
T2
- Uncommitted:
T3
|
- Recovery:
- Redo portion:
Starting from the
<START CKPT> record,
redo all
actions for T2
Undo/redo log:
<START T1>
<T1, A, 4, 5>
<START T2>
<COMMIT T1> ==== T1 done
<T2, B, 9, 10>
============================
<START CKPT(T2)>
<T2, C, 14, 15> <--+ Between here:
<START T3> | **** OUTPUT(A) and OUTPUT(B)
<T3, D, 19, 20> <--+
<END CKPT> // Flush Log
<COMMIT T2> ===== T2 done
+++++++++++++++++++++++++++++++++++++++ System crashed....
<COMMIT T3> ===== T3 done
(OUTPUT for T2 and T3 happens later)
|
- Resulting actions:
- Note:
- B
has been updated by
the checkpoint operation !!!
|
- Undo portion:
- Because T3 is
not a transaction
mention in the
<START CKPT(T2)>
record, we can
stop at the
<START CKPT(T2)>
record !!!
|
Stopping from the
<START CKPT(T2)> record,
undo all
actions for T3
Undo/redo log:
<START T1>
<T1, A, 4, 5>
<START T2>
<COMMIT T1> ==== T1 done
<T2, B, 9, 10>
============================
<START CKPT(T2)>
<T2, C, 14, 15> <--+ Between here:
<START T3> | **** OUTPUT(A) and OUTPUT(B)
<T3, D, 19, 20> <--+
<END CKPT> // Flush Log
<COMMIT T2> ===== T2 done
+++++++++++++++++++++++++++++++++++++++ System crashed....
<COMMIT T3> ===== T3 done
(OUTPUT for T2 and T3 happens later)
|
- Resulting actions:
|
|