Deadlock and live lock. How will you go about resolving deadlocks?

What is a deadlock and what is a live lock? How will you go about resolving deadlocks?

Deadlock occurs when two user processes/transactions have locks on 2 separate objects and each process is trying to acquire a lock on the object that has been acquired by the other process. In such a scenario each process is waiting for the other process to release the lock to acquire a lock on the object itself. When a request for exclusive lock is denied again and again because a series of overlapping shared locks are interfering with each other and to adapt from each other they keep on changing the status, it is known as live lock.

One can resolve deadlocks by using TRY CATCH blocks. If the code inside a TRY statement fails, the CATCH automatically catches the control of the flow letting the transaction rollback and resume execution.

What is a deadlock and what is a live lock? How will you go about resolving deadlocks?

A deadlock occurs when two or more processes waits for a resource that is acquired by or is under the control of another process. A live lock is similar to a deadlock except the process states keeps changing. The result of such state is that none of the process will be complete.

Deadlock detection finds and resolves deadlocks. A WFG strategy is followed. WFG is wait for graph. In WFG, processes are represented by nodes while dependencies are represented by edges. Thus, if process A is waiting for a resource held by process B, there is an edge in the WFG from the node for process A to the node for process B. a cycle is this graph is a deadlock. WFG constantly checks for cycles or when a process is blocked and adds a new edge to the WFG. When a cycle is found, a victim is selected and aborted.
What is blocking and how would you troubleshoot it?
What is blocking and how would you troubleshoot it? - Blocking occurs when two or more rows are locked by one SQL connection and a second connection to the SQL server requires a conflicting on lock on those rows........
Different types of BACKUPs available in SQL Server
Different types of BACKUPs available in SQL Server - Complete database backup: This type of backup will backup all the information in the database. Used most commonly for disaster recovery and takes the longest time to backup........
What is database isolation in SQL Server?
What is database isolation in SQL Server? - Isolation in database defines how and when changes made by one transaction can be visible to other transactions......
Post your comment