Why Recovery Is
Needed:
Whenever a transaction is
submitted to a DBMS for execution, the system is responsible for making sure
that either all the operations in the transaction are completed successfully
and their effect is recorded permanently in the database, or that the transaction
does not have any effect on the database or any other transactions.
In
the first case, the transaction is said to be committed,
whereas in the second case, the transaction is aborted.
The
DBMS must not permit some operations of a transaction T to be applied to the
database while other operations of T are not, because the whole transaction is
a logical unit of database processing. If a transaction fails
after executing some of its
operations but before executing all of them, the operations already executed
must be undone and have no lasting effect.
Types of Failures:
Failures
are generally classified as transaction, system, and media failures. There are
several possible reasons for a transaction to fail in the middle of execution:
Ø A computer failure (system crash): A hardware, software, or network error occurs in the computer system during transaction execution. Hardware crashes are usually media failures.
For example: main memory failure.
Ø A
transaction or system error: Some operation in the
transaction may cause it to fail, such as integer overflow or division by zero.
Transaction failure may also occur because of erroneous parameter values or
because of a logical programming error. Additionally, the user may interrupt
the transaction during its execution.
Ø Local
errors or exception conditions detected by the transaction: During
transaction execution, certain conditions may occur that necessitate
cancellation of the transaction.
For example: data for the transaction may not be
found. An exception condition, such as insufficient account balance in a
banking database, may cause a transaction, such as a fund withdrawal, to be
canceled. This exception could be programmed in the transaction itself, and in
such a case would not be considered as a transaction failure.
Ø Concurrency
control enforcement: The concurrency
control method (see Chapter 22) may decide to abort a transaction because it
violates serializability (see Section 21.5), or it may abort one or more
transactions to resolve a state of deadlock among several transactions (see
Section 22.1.3). Transactions aborted because of serializability violations or
deadlocks are typically restarted automatically at a later time.
Ø Disk
failure. Some disk blocks may lose
their data because of a read or write malfunction or because of a disk
read/write head crash. This may happen during a read or a write operation of
the transaction.
Ø Physical
problems and catastrophes. This refers to an
endless list of problems that includes power or air-conditioning failure, fire,
theft, sabotage, overwriting disks or tapes by mistake, and mounting of a wrong
tape by the operator.
Failures
of types 1, 2, 3, and 4 are more common than those of types 5 or 6. Whenever a
failure of type 1 through 4 occurs, the system must keep sufficient information
to quickly recover from the failure.
Disk
failure or other catastrophic failures of type 5 or 6 do not happen frequently;
if they do occur, recovery is a major task.
Data recovery: Data recovery is the process of restoring data that has been lost,
accidentally deleted, corrupted or
made inaccessible. Recovery from transaction
failures usually means that the database is restored to the most recent consistent state just before
the time of failure.
The concept of transaction is fundamental to many techniques for concurrency control and recovery from failures.
Comments
Post a Comment