Ch4-Crash Recovery (1)
Ch4-Crash Recovery (1)
Crash Recovery
Recovery
• A crash is the sudden failure of a software application or
operating system or of a hardware device such as a hard
disk.
• Database recovery is the process of restoring the database
to a consistent state in the event of a failure.
• In other words, it is the process of restoring the database to
the most recent consistent state that existed shortly before
the time of system failure.
• Recovery is required to protect the database from data
inconsistencies and data loss.
• Recovery is done by rolling back incomplete transactions
and completing committed transactions that were still in
memory when the crash occurred.
Classification of Transaction Failure
Classification of Transaction Failure
Failure can be
• Simple-No Loss of data or information
• Complex- Loss of data or information
1.Transaction Failure
There are 2 types of errors
a) System Error-deadlock condition
b) Logical Error-some mistakes in the code or
presence of some internal faults.
2. System Crash
failure of the transaction, operating system errors, power
cuts, main memory crash etc.
3. Disk Failure
Disk head crash, disk unreachability , formation of bad
sectors, read write errors on the disk
Transaction Logging
Transaction Logging
• To recover from failures, database systems maintain a
transaction log, which records all changes made by
transactions. The log includes information about what
operations were performed, the data affected, and
when they were executed.
Recovery and Log
• Log -The most widely used structure for recording
modifications to database.
• It records significant events during transaction
processing.
• Update log records contains following fields:
• Transaction identifier is the unique identifier of the
transaction that performed the write operation.
• Data-item identifier is the unique identifier of the data
item written. It is the location on disk of the data item.
• Old value is the value of the data item prior to the
write.
• New value is the value that the data item will have
after the write.
• Other special log records such as the start of a
transaction and the commit or abort of a transaction.
Update log:
• It describes a single database write and it is denoted
as: <Ti,Xj,V1,V2>
where, Ti –Transaction identifier
Xj- Data item identifier
V1 – Old value of Xj
V2 - New value of after the write operation.
• Transaction commits: denoted as <Ti commit>
• Transaction abort: denoted as:<Ti abort>
Recovery with concurrent
transactions
• Rollback
• Checkpoint
• Commit
Rollback
•
•
•
Rollback
•I/O Operations of OS
•Recovery fro hardware &
software failure
•Recover DB in case of
failure by log files,
commit and abort of
transactions
ARIES Algorithm
• Algorithm for Recovery and Isolation Exploiting Semantics
It is based on the Write Ahead Log (WAL) protocol.
Every update operation writes a log record which is one of
the following :
• Analysis: The analysis phase identifies the dirty (updated)
pages in the buffer and the set of transactions active at the
time of the crash. The appropriate point in the log where
the REDO operation should start is also determined.
• Undo-only log record:
Only the before image is logged. Thus, an undo operation
can be done to retrieve the old data.
• Redo-only log record:
Only the after image is logged. Thus, a redo operation can
be attempted.
• Undo-redo log record:
Both before images and after images are logged.
ARIES Algorithm