/    /  DBMS- Recovery from Deadlock

Recovery from Deadlock


When a detection algorithm detects that there is a deadlock, the system must be able to recover from the deadlock.


The most common solution to recover from the dead-lock situation is to roll back one or more transactions and break the deadlock.


Here, three actions are needed to be taken :


 (a)Selection of a Victim :

Given a set of deadlocked transactions, one must determine which transaction has to be rolled back to break the deadlock. Then, that transaction should be rolled back which occurs at minimum cost. Many other factors also play a role in deciding which transactions need to be rolled back.




 (b)Rollback :

Once it is decided that a particular transaction must be rolled back, then determine how far this transaction should be rolled back.

The simplest solution is ‘Total Rollback’. That is, we abort the transaction and then restart it.



Sometimes, it is possible to do ‘partial rollback’, which retains the consistency of the database. ‘Partial Rollback’ requires the system to maintain additional information about the state of all the running transactions.



In a system where the selection of a transaction is based primarily on cost factors, then it is possible to pick the same transaction to be rolled back, known as ‘victim’. As a result, the transaction never completes its designated task, thus there is a ‘starvation’. So, here one should decide that a selected transaction be rolled back for a finite number of times only.  Then ‘starvation’ does not occur.



Reference Link

Recovery from Deadlock