7 Database Recovery
7 Database Recovery
7 Database Recovery
Recovery brings the database from the temporary inconsistent state to a consistent state.
Database recovery can also be defined as mechanisms for restoring a database quickly and
accurately after loss or damage. Databases are damaged due to human error, hardware failure,
incorrect or invalid data, program errors, computer viruses, or natural catastrophes. Since the
organization depends on its database, the database management system must provide
mechanisms for restoring a database quickly and accurately after loss or damage.
1
7.2.2 Logging Facilities
The two types of logs are “transaction log” and “database change log.” A transaction log is a
record of the essential data for each transaction that is processed against the database. In
database change log, there are before and after images of records that have been modified.
Transaction log. Transaction log contains a record of the essential data for each transaction that
is processed against the database. Data that are typically recorded for each transaction include
the transaction code or identification,
action or type of transaction, time of the transaction, terminal number or user ID, input data
values, table and records accessed, records modified, and possibly the old and new field values.
Database change log. The database change log contains before and after images of records that
have been modified by transactions. A before-image is a copy of a record before it has been
modified, and an after-image is a copy of the same record after it has been modified.
2
in log, then that transaction was active at failure and must be undone. Undo operations are
performed in reverse order in which they were written to log.
Shadow paging. Shadow paging maintains two-page tables during life of a transaction, current
page and shadow page table. When transaction starts, two pages are the same. Shadow page
table is never changed thereafter and is used to restore database in the event of failure. During
transaction, current page table records all updates to database.
Crash Recovery
Crash recovery is the process of protecting the database from catastrophic system failures and
media failures. Recovery manager of a DBMS is responsible for ensuring transaction atomicity
and durability. Atomicity is attained by undoing the actions of transactions that do not commit.
Durability is attained by making sure that all actions of committed transactions survive system
crashes.