Adv DB CHapter 5
Adv DB CHapter 5
Changes are not applied immediately to the Changes are applied directly to the database
database
Log file contain changes that are to be applied to Log file contains old as well as new values
database.
In this once rollback is done. All the records of In this method one rollback is done the old values
log file are discarded & no changes applied to are restored in database using records of log file
database.
Concepts of buffering & catching is used.
It requires a lot of time for recovery in case of
system failure. Concepts of shadow paging is used.
There are frequent I/O operations while
transaction is active.
Write-Ahead Logging, Steal/No-Steal, and Force/No-Force
• When in-place updating is used, it is necessary to use a log for recovery
• In this case, the recovery mechanism must ensure that the BFIM of the
data item is recorded in the appropriate log entry and that the log entry
is flushed to disk before the BFIM is overwritten with the AFIM in the
database on disk. This process is generally known as write-ahead
logging
• Two types of log entry information included for a write command:
• the information needed for UNDO
• the information needed for REDO
• A REDO-type log entry includes the new value (AFIM) of the item
written by the operation.
• The UNDO-type log entries include the old value (BFIM) of the item
since this is needed to undo the effect of the operation from the log.
Standard DBMS recovery terminology
• no-steal approach - If a cache buffer page updated by a transaction
cannot be written to disk before the transaction commits.
• The no-steal rule means that UNDO will never be needed during
recovery.
• steal approach - if the recovery protocol allows writing an updated
buffer before the transaction commits.
• Steal is used when the DBMS cache (buffer) manager needs a buffer
frame for another transaction and the buffer manager replaces an
existing page that had been updated but whose transaction has not
committed.
• force approach - If all pages updated by a transaction are immediately
written to disk before the transaction commits.
Standard DBMS recovery terminology…
• The force rule means that REDO will never be needed during recovery
• The deferred update (NO-UNDO) recovery scheme follows a no-steal
approach.
• However, typical database systems employ a steal/no-force
(UNDO/REDO) strategy.
• The advantage of steal is that it avoids the need for a very large buffer
space to store all updated pages in memory.
• The advantage of no-force is that an updated page of a committed
transaction may still be in the buffer when another transaction needs to
update it.
• thus eliminating the I/O cost to write that page multiple times to disk
and possibly having to read it again from disk.
Checkpoints in the System Log
• Another type of entry in the log is called a checkpoint.
• A [checkpoint, list of active transactions] record is written into the log
periodically at that point when the system writes out to the database on disk all
DBMS buffers that have been modified.
• all transactions that have their [commit, T ] entries in the log before [checkpoint]
entry do not need to have their WRITE operations redone in case of a system
crash, since all their updates will be recorded in the database on disk during
checkpointing.
• The recovery manager of a DBMS must decide at what intervals to take a
checkpoint.
• The interval may be measured in time say, every m minutes or in the number t of
committed transactions since the last checkpoint, where the values of m or t are
system parameters.
Transaction Rollback and Cascading Rollback
• If a transaction fails for whatever reason after updating the database, but
before the transaction commits, it may be necessary to roll back the
transaction.
• Cascading rollback:
• Is a situation in which when one transaction rolled back, the other
transaction that reads the value of some data item written by the
previous transaction is also rolled back and so on.
• If a transaction T is rolled back, any transaction S that has, in the
interim, read the value of some data item X written by T must also be
rolled back.
• Similarly, once S is rolled back, any transaction R that has read the value
of some data item Y written by S must also be rolled back; and so on.
• it can occur when the recovery protocol ensures recoverable schedules
but does not ensure strict or cascadeless schedules.
• can be complex and time-consuming.
NO-UNDO/REDO Recovery Based on Deferred Update
• The idea behind deferred update is to defer or postpone any actual
updates to the database on disk until the transaction completes its
execution successfully and reaches its commit point.
• If a transaction fails before reaching its commit point, there is no
need to undo any operations because the transaction has not
affected the database on disk in any way.
• only REDO type log entries are needed in the log, which include
the new value (AFIM) of the item written by a write operation.
• REDO is needed in case the system fails after a transaction
commits but before all its changes are recorded in
the database on disk.
NO-UNDO/REDO Recovery Based on Deferred Update