Database Log file
=================================================
<START T>
...
Write(X1) <T, X1, v1>
...
Write(X2) <T, X2, v2>
...
COMMIT <COMMIT T> ++++++++
FLUSH log
Later on, the DBMS make updates at its convenience:
...
<OUTPUT X1>
...
<OUTPUT X2>
|
|
This property is the result of the redo log update rule:
Transaction manager executes an operation
/* ==================================================================
Redo log write rule:
Only update database elem's modified by committed transactions.
================================================================== */
if ( operation = OUTPUT(X) )
{
/* =============================================
Database elem X was updated by transaction T
============================================= */
if ( T's state == COMMITTED )
{
FLUSH log; // Write all log records to disk
// including the log records belonging to T
// We made sure that all updates by T can be (re)done
OUTPUT(X); // (When) we make one of the updates of T to disk
}
else
{
return; // Do not write data updated by
// an uncomitted transaction to disk !!!
}
}
else
{
perform operation;
}
|
Database Log file
=================================================
<START T>
...
Write(X1) <T, X1, v1>
...
Write(X2) <T, X2, v2>
...
COMMIT <COMMIT T> ++++++++
FLUSH log
Later on, the DBMS make updates at its convenience:
...
<OUTPUT X1>
...
<OUTPUT X2>
|
|
|
Example:
|
|
Example:
|
|
|
/* ==================================================
Step 1: identify the commited transactions
================================================== */
Scan the redo log:
{
identify the committed transaction
identify also the UNcommitted transaction (for writing abort records)
}
/* ==================================================
Step 2: redo the commited transactions
================================================== */
Scan the undo log forewards:
{
For ( each < T, A, v > where T is commited ) do
{
Update A with the (after) value v; // Redo the change !!!
}
}
/* =========================================================
Step 3: mark the uncommited tranasactions as failed....
========================================================= */
For ( each T that is uncommited ) do
{
Write <ABORT T> to log;
}
Flush-Log
|
|
Notice that:
|
|
Recovery:
|
Comment:
|
|
Recovery:
|
Comment:
|
|
2 possibilities:
|
Recovery if <COMMIT T> was written to disk:
|
Comment:
|
Recovery if <COMMIT T> was not written to disk:
|
Comment:
|
|
The <COMMIT T> record will not have been written !!!
Recovery:
|
Comment:
|