Saturday, April 26, 2014

Deadlock Prevention algorithms in Database

What are the deadlock prevention algorithms in database?

Notes and Tutorials on How to prevent deadlock? / How to prevent deadlock in DBMS? / Deadlock prevention techniques  in DBMS / Wait-die and Wound-wait in DBMS / Database deadlock avoidance / Wait-die and Wound-wait example


The Deadlock prevention protocol prevents the system from deadlock through transaction rollbacks. It chooses rollback over waiting for the lock whenever the wait could cause a deadlock. In this approach we have the following two deadlock prevention algorithms;

1. Wait-die scheme


2. Wound-wait scheme


Assume that a transaction T1 requests for a lock on a data item X. And, the data item X is already locked by another transaction T2 in an incompatible mode. Now the question is “Can we allow transaction T1 to wait or to roll-back?” The Deadlock Prevention algorithm works by allowing a transaction to wait or force it to roll-back to prevent the occurrence of deadlock.


Points to note:

1. Deadlock prevention technique is used for a system for which the possibilities for entering a deadlock state are high.
2. Using 2 Phase Locking protocol to lock all the required data items at once may help in preventing deadlock at the cost of lower data-item utilization.
3. Every time Wait-die or Wound-wait roll-back a transaction, it is very important to ensure that the system does not choose the same transaction repeatedly. The repeated rollback of same transaction will lead to the state called Starvation. Both Wait-die and Wound-wait avoids starvation. This is handled by issuing the same timestamp for the transaction which is rolled back.
4. In Wait-die scheme, older transaction waits. In Wound-wait scheme, older transaction never waits.
5. The major drawback: both schemes lead to unnecessary rollbacks.

Related Links

Deadlock in database
Deadlock detection techniques INDEX
Database management systems home page  



Deadlock prevention in dbms

How to prevent deadlock in database management systems

Wait die and wound wait algorithm in deadlock prevention


Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

data recovery