Slideshow:
|
|
|
|
|
|
|
Consequence:
|
|
/* ==================================================
Step 1: identify the uncommited transactions
================================================== */
Scan the undo log:
{
identify the uncommitted/aborted transactions
(I.e.: find the transactions T that:
has: <START T>
but no: <COMMIT T>
)
}
/* =============================================================
Step 2: undo the uncommited/aborted transactions
in the reverse order
Updates: write 1 --> write 2 --> write 3
Undos: undo write 3 --> undo write 2 --> undo write 1
============================================================= */
Scan the undo log backwards:
{
For ( each < T, A, v > in undo log )
{
if ( T is uncommited )
Update A with the (before) value v; // Undo the action !!!
}
}
/* =========================================================
Step 3: mark the uncommited tranasactions as failed....
========================================================= */
For ( each T that is uncommited ) do
{
Write <ABORT T> to log;
}
Flush-Log
|
|
Color-code in the loggoing example:
|
Notice there are 2 possible consistent database states:
|
|
Recovery:
|
Comment:
|
|
2 possibilities:
|
Recovery if <COMMIT T> was written:
|
Comment:
|
Recovery if <COMMIT T> was not written:
|
Comment:
|
|
The <COMMIT T> record will not have been written !!!
Recovery:
|
Comment:
|
|
Then:
|
Recovery:
|
Comment:
|
|
Then:
|
Recovery:
|
Comment:
|