Deadlock In Database

Download PDF
Advertisement

Deadlock In Database

Deadlock In Database: Record locking mechanism may create an undesirable situation where two or more users are waiting for the completion of each other’s actions. This situation is called deadlock.

Controlling Deadlock

There are different methods to control the situation of the deadlock. The most common method is deadlock prevention. In deadlock prevention, it is required that all the needed records are locked in the beginning of the transaction. No record is locked afterwards until the completion of the transaction. If at the beginning of the transaction some records are already locked, then the transaction must wait to start until all the needed records are released.

Another method is deadlock resolution in which DBMS takes its responsibility, to solve the deadlock situations.

Backups

Data is as important for any organization as blood in human body. In case data becomes unavailable due to any reason, all the working of the organization stops and it becomes unamenable loss. In order to avoid such big loss, DBA must take backup of his database frequently according to the nature of the database. Backup can be defined as second copy of the original database produced by backup facilities provided by DBMS or operating system. This second copy or saved copy of original database is produced on separate storage media such as magnetic tape, magnetic disk and optical disk. These should be placed in a separate and secure location, where unauthorized do not have any access.

Backups can be taken manually through the DBA or these can be taken automatically by configuring the DBMS. In case of the automatic backups, you must specify day, time and location on storage media where DBMS will take the backups. These settings are required when configuration the DBMS.

Types of Backups

There are two important types of backups

  1. Hot Backup
  2. Cold Backup

Hot Backup

Hot backup is taken when database is running and the data is being updated, added, or read by its users. The connected users are disconnected. Only DBMS facility can be used to take hot backup. Hot backup is taken in environment where database is needs to remain only 24-hours a day and 7-days a week. The Hot Backup is also referred to as Online Backup.

Advertisement

Cold Backup

Cold Backup is taken when database is offline. The Cold Backup is referred to as Offline Backup. The DBMS as well as operating system facilities can be used to take the cold backup. Normally, cold backup is taken at the end of a working day or at weekends when database comes offline. Cold backup is suitable in environment where the database is not running 24-hours a day. Instead, there are some time intervals when it remain off. It is an important process to avoid deadlock in database.

Recovery

Database can fail due to some reason like media failure, operating system failure, accidental damage, intentional damage to the database etc. In case, database stops working due to any reason, it is responsibility of DBA to recover it with the help of backup copy of database. Recovery can be defined as “the restoration of database, in case of its failure, into the state it was in, before its failure”.

Almost, every DBMS provides a number of facilities to restore database. When the size of database is large, recovery process may take a lot of time. In this case when a complete recovery procedure is required to completely recover the database.

Mostly the following methods are used to recover the data through log file.

Backward Recovery

Backward Recovery is also called Rollback recovery. In this type of recovery, database is restored into the previous state and the unwanted changes are eliminated. It means that all changes made by various transactions are undone.

Forward Recovery

Forward Recovery is also called Roll-forward. Changes of some failed transactions are applied to the database in order to roll it forward. Thus, database becomes updated with all the changes confirmed.

 

Record Locking In Database

Advertisement