0% found this document useful (0 votes)
287 views10 pages

DEADLOCK

Deadlock occurs in a database when two or more transactions are waiting indefinitely for each other to release locks on resources. This brings the entire system to a halt. To prevent deadlocks, techniques like deadlock avoidance and deadlock prevention are used. Deadlock avoidance involves applying application logic to access resources in the same order consistently. Deadlock prevention methods like wait-die and wound-wait schemes prioritize older transactions to resolve deadlocks.

Uploaded by

Shalom Alexander
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
287 views10 pages

DEADLOCK

Deadlock occurs in a database when two or more transactions are waiting indefinitely for each other to release locks on resources. This brings the entire system to a halt. To prevent deadlocks, techniques like deadlock avoidance and deadlock prevention are used. Deadlock avoidance involves applying application logic to access resources in the same order consistently. Deadlock prevention methods like wait-die and wound-wait schemes prioritize older transactions to resolve deadlocks.

Uploaded by

Shalom Alexander
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Deadlock in DBMS

What is Deadlock?
• In a database, a deadlock is an unwanted
situation in which two or more transactions
are waiting indefinitely for one another to give
up locks.
Consequence of Deadlock!!
• Deadlock is said to be one of the most feared
complications in DBMS as it brings the whole
system to a Halt.
Example:-
Transaction T1 will wait for transaction T2 to give up lock, and
similarly transaction T2 will wait for transaction T1 to give up
lock. As a consequence, All activity comes to a halt
What can you do ?
Two most suitable techniques are:
• Deadlock avoidance method is suitable for
smaller database
• Deadlock prevention method is suitable for
larger database.
Deadlock Avoidance
• One method of avoiding deadlock is using
application consistent logic.
Example:
• Transactions that access Students and Grades should always access the
tables in the same order.
• ie. Transaction T1 simply waits for transaction T2 to release the lock
on Grades before it begins. When transaction T2 releases the lock,
Transaction T1 can proceed freely.
Deadlock Detection
• Wait For Graph
In this method a graph is drawn based on the transaction and
their lock on the resource. If the graph created has a closed
loop or a cycle, then there is a deadlock.
Deadlock Prevention
• Wait-Die Scheme –
1. Checks if TS (T1) < TS (T2)
2. if T1 is the older transaction and T2 has held some resource, then it
allows T1 to wait until resource is available for execution.
3. If T1 is older transaction and has held some resource with it and if T2 is
waiting for it, then T2 is killed and restarted again with same timestamp.
Deadlock Prevention
• Wound Wait Scheme –
• if an older transaction requests for a resource held by younger
transaction, then older transaction forces younger transaction to kill the
transaction and release the resource.
• If the younger transaction is requesting a resource which is held by older
one, then younger transaction is asked to wait till older releases it.

Older
transaction Younger
transaction
Thank You!!!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy