What is Deadlock condition in DBMS ? Anonymous User 687 03-Dec-2019 When, why and how does a database encounter deadlock? database database sql server dbms Updated on 03-Dec-2019
Can you answer this question?
Deadlock condition in DBMS
The deadlock is a condition where two or more transactions are waiting indefinitely for one another to give up locks. The Deadlock is said to be one of the most feared complications in DBMS as no task ever gets finished and is in waiting for state forever.
Into the Employee table, transaction Tab1 holds a lock on some rows and needs to update some rows in the grade table. Simultaneously, transaction Tab2 holds locks on some rows in the grade table and needs to update the rows in the Employee table held by Transaction Tab1. And now, the main problem arises. This means the Transaction Tab1 is waiting for Tab2 to release its lock and similarly, transaction Tab2 is waiting for Tab1 to release its lock. Each activity comes to a halt state and remains at a standstill. That will remain in a standstill until the DBMS detects the deadlock and aborts one of the transactions.
The resource scheduler can detect a deadlock as it keeps track of all the resources that are allocated to different processes. After a deadlock is detected, it can be resolved using the following methods:
This is better to avoid a deadlock rather than take measures after the deadlock has occurred. Here the wait for the graph can be used for deadlock avoidance. That is however only useful for smaller databases as it can get quite complex in larger databases.
For the larger database, the deadlock prevention method can be used.