Database Management System: Unit III: Transactions

Recovery Concepts

Transactions - Database Management System

i) This error is caused due to internal conditions such as bad input, data not found,overflow of resource limit and so on. ii) Due to logical error the transaction can not be continued.

Part III: Recovery

Recovery Concepts

An integral part of a database system is a recovery scheme that can restore the database to the consistent state that existed before the failure.

The recovery scheme must also provide high availability; that means, it must minimize the time for which the database is not usable after a failure.

Failure Classification

Various types of failures are -

1. Transaction Failure: Following are two types of errors due to which the transaction gets failed.

Logical Error:

i) This error is caused due to internal conditions such as bad input, data not found,overflow of resource limit and so on.

ii) Due to logical error the transaction can not be continued.

System Error:

i) When the system enters in an undesired state and then the transaction can not be continued then this type of error is called as system error.

2) System Crash: The situation in which there is a hardware malfunction, or a bug in the database software or the operating system, and because of which there is a loss of the content of volatile storage, and finally the transaction processing come to a halt is called system crash.

3) Disk Failure: A disk block loses its content as a result of either a head crash or failure during a data-transfer operation. The backup of data is maintained on the secondary disks or DVD to recover from such failure.

Storage

A DBMS stores the data on external storage because the amount of data is very huge and must persist across program executions.

The storage structure is a memory structure in the system. It has following categories -

1) Volatile :

Volatile memory is a primary memory in the system and is placed along with the CPU.

These memories can store only small amount of data, but they are very fast. Forexample - main memory, cache memory.

A volatile storage cannot survive system crashes.

That means data in these memories will be lost on failure.

2) Non Volatile :

Non volatile memory is a secondary memory and is huge in size. For example: Hard disk, Flash memory, magnetic tapes.

These memories are designed to withstand system crashes.

3) Stable :

Information residing in stable storage is never lost.

To implement stable storage, we replicate the information in several nonvolatile storage media (usually disk) with independent failure modes.

Stable Storage Implementation

Stable storage is a kind of storage on which the information residing on it is never lost.

Although stable storage is theoretically impossible to obtain it can be to approximately built by applying a technique in which data loss is almost impossible.

That means the information is replicated in several nonvolatile storage media with independent failure modes.

Updates must be done with care to ensure that a failure during an update to stable storage does not cause a loss of information.

Recovery with Concurrent Transactions

There are four ways for recovery with concurrent transactions:

1) Interaction with concurrency control: In this scheme recovery depends upon the concurrency control scheme which is used for the transaction. If a transaction gets failed, then rollback and undo all the updates performed by transaction.

2) Transaction Rollback: In this scheme, if the transaction gets failed, then the failed ear transaction can be rolled back with the help of log. The system scans the log backward, and with the help of log entries the system can restore the data items.

3) Checkpoints: The checkpoints are used to reduce the number of log records.

4) Restart recovery: When the system recovers from the crash it constructs two lists: Undo-list and Redo-list. The undo list consists of transactions to be undone. The redo list consists of transactions to be redone. These two lists are handled as follows

Step 1: Initially both the lists are empty.

Step 2: The system scans the log entries from backwards. It scans each entry until it finds first checkpoint record.

Shadow Copy Technique

In the shadow-copy scheme, a transaction that wants to update the database first creates a complete copy of the database.

All updates are done on the new database copy, leaving the original copy, the shadow copy, untouched.

If at any point the transaction has to be aborted, the system merely deletes the new copy. The old copy of the database has not been affected.

The current copy of the database is identified by a pointer, called db-pointer, which is stored on disk.

If the transaction partially commits, it is committed as follows:

    • First, the operating system is asked to make sure that all pages of the new copy of the database have been written out to disk.

   • After the operating system has written all the pages to disk, the database system updates the pointer db-pointer to point to the new copy of the database.

    • The new copy then becomes the current copy of the database.

    • The old copy of the database is then deleted.

The transaction is said to have been committed at the point where the updated db-pointer is written to disk.

The disk system guarantees that it will update db-pointer atomically, as long as we make sure that db-pointer lies entirely in a single sector.

Where is shadow copy technique used?

  • Shadow copy schemes are commonly used by text editors.

  • Shadow copying can be used for small databases.

Database Management System: Unit III: Transactions : Tag: : Transactions - Database Management System - Recovery Concepts