1
25kviews
Explain log based recovery

Mumbai University > Information Technology > Sem 3 > Database Management System

Marks: 10 M

Year: Dec 2013

3
774views

### 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, which contains history of all transaction performed
• Log contains Start of transaction, trans-id, record-id, type of operation (insert, update, delete), old value, new value, End of transaction that is commit or aborted.

### There are several types of log records.

• Transaction identifier
• Data-item identifier
• Old value
• New value
• Whenever a transaction performs a write, it is essential that the log record for that write be created before the database is modified.
• Once a log record exists, we can output the modification that has already been output to the database, by using the old value field in the log records.

Log based recovery works as follows:

• The log file is kept on stable storage media
• When a transaction enters the system and starts execution, it writes a log about it
• <Tn, Start>
• When the transaction modifies an item X, it write logs as follows:
• <Tn, X, V1, V2>

It reads Tn has changed the value of X, from V1 to V2.

• When transaction finishes, it logs:

• <Tn,commit>

Database can be modified using two approaches:

Deferred database modification: All logs are written on to the stable storage and database is updated when transaction commits.

Immediate database modification: Each log follows an actual database modification. That is, database is modified immediately after every operation.