Physical blocks are those blocks residing on the disk
Buffer blocks are the blocks residing temporarily in main memory
Block movements between disk and main memory are initiated through the following two operations
input(A) transfers the physical block A to main memory
output(B) transfers the buffer block B to the disk
Transaction transfers data items between system buffer blocks and its private work-area using the following operations :
read(X) assigns the value of data item X to the local variable xi
write(X) assigns the value of local variable xi to data item X in the buffer block
both these commands may issue an input(BX) instruction before the assignment, if the block BX in which X resides is not in main memory
Log-Based Recovery
When transaction Ti starts, it registers itself by writing a log record
Before Ti executes write(X), a log record <Ti, X, V1, V2> is written, where V1 is the value of X before the write (the old value), and V2 is the value to be written to X (the new value)
When Ti finishes it last statement (partially committed state), the log record is written. Then the transaction enters the committed state
Concurrency Control and Recovery
Undo and Redo Operations
undo(Ti) – restores the value of all data items updated by Ti to their old values, going backwards from the last log record for Ti
Each time a data item X is restored to its old value V a special log record <Ti , X, V> is written out
When undo of a transaction is complete, a log record is written out
redo(Ti) – sets the value of all data items updated by Ti to the new values, going forward from the first log record for Ti
No logging is done in this case
Recovering from Failure
When recovering after failure:
Transaction Ti needs to be undone if the log
Contains the record , But does not contain either the record or
Transaction Ti needs to be redone if the log
Contains the records And contains the record or
Checkpoints
Streamline recovery procedure by periodically performing checkpointing
Output all log records currently residing in main memory onto stable storage
Output all modified buffer blocks to the disk
Write a log record onto stable storage where L is a list of all transactions active at the time of checkpoint
All updates are stopped while doing checkpointing
During recovery we need to consider only the most recent transaction Ti that started before the checkpoint, and transactions that started after Ti
Scan backwards from end of log to find the most recent record
Only transactions that are in L or started after the checkpoint need to be redone or undone
Transactions that committed or aborted before the checkpoint already have all their updates output to stable storage
Redo phase:
Find last record, and set undo-list to L
Scan forward from above record
Whenever a record <Ti, Xj, V1, V2> or <Ti, Xj, V2> is found, redo it by writing V2 to Xj
Whenever a log record is found, add Ti to undo-list
Whenever a log record or is found, remove Ti from undo-list
Undo phase:
Scan log backwards from end
Whenever a log record <Ti, Xj, V1, V2> is found where Ti is in undo-list perform same actions as for transaction rollback:
perform undo by writing V1 to Xj
write a log record <Ti , Xj, V1>
Whenever a log record is found where Ti is in undo-list
Write a log record
Remove Ti from undo-list
Stop when undo-list is empty, i.e., has been found for every transaction in undo-list