Database Management Systems (2130703)

BE | Semester-3   Summer-2018 | 05/23/2018

Q5) (a)

What is log based recovery? Explain Immediate database modification technique for database recovery.

Log based recovery

  • The most widely used structure for recording database modification is the log.
  • The log is a sequence of log records, recording all the update activities in the database.
  • In short Transaction log is a journal or simply a data file, which contains history of all transaction performed and maintained on stable storage.
  • Since the log contains a complete record of all database activity, the volume of data stored in the log may become unreasonable large.
  • For log records to be useful for recovery from system and disk failures, the log must reside on stable storage.
  • Log contains
    1. Start of transaction
    2. Transaction-id
    3. Record-id
    4. Type of operation (insert, update, delete)
    5. Old value, new value
    6. End of transaction that is committed or aborted.
  • All such files are maintained by DBMS itself. Normally these are sequential files.
  • Recovery has two factors Rollback (Undo) and Roll forward (Redo).
  • When transaction Ti starts, it registers itself by writing a < Ti start >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, and V2 is the value to be written to X.
    • Log record notes that Ti has performed a write on data item Xj
    • Xj had value V1 before the write, and will have value V2 after the write.
  • When Ti finishes it last statement, the log record < Ti commit> is written.

Immediate Database Modification

Concept

  • Updates (changes) to the database are applied immediately as they occur without waiting to reach to the commit point.
  • Also, these updates are recorded in the transaction log.
  • It is possible here that updates of the uncommitted transaction are also written to the database. And, other transactions can access these updated values.

When failure occurs

  • If transaction has not committed, then it may have modified the database. And so, undo the updates of the transaction.
  • If transaction has committed, then still it may not have modified the database. And so, redo the updates of the transaction.