SlideShare a Scribd company logo
2
Most read
3
Most read
10
Most read
Deadlock in Database
Deadlock:
 Deadlock is a state of a database system having two or
more transactions, when each transaction is waiting for
a data item that is being locked by some other
transaction. A deadlock can be indicated by a cycle in
the wait-for-graph. This is a directed graph in which the
vertices denote transactions and the edges denote waits
for data items.
Example:
 For example, in the following wait-for-graph,
transaction T1 is waiting for data item X which is locked
by T3. T3 is waiting for Y which is locked by T2 and T2 is
waiting for Z which is locked by T1. Hence, a waiting
cycle is formed, and none of the transactions can
proceed executing.
DEADLOCK HANDLING
• when a deadlock occurs, different operating
systems respond to them in different non-
standard manners.
• The Major approaches are as follows
 IGNORING DEADLOCK
 DETECTION
IGNORING DEADLOCK
In this approach, it is assumed that a deadlock will never
occur. This is also an application of the Ostrich algorithm.
This approach was initially used by MINIX and UNIX. This is
used when the time intervals between occurrences of
deadlocks are large and the data loss incurred each time
is tolerable
DETECTION
 The deadlock detection and
removal approach runs a
deadlock detection algorithm
periodically and removes
deadlock in case there is one.
Prevention:
 The deadlock prevention approach does
not allow any transaction to acquire locks
that will lead to deadlocks. The convention
is that when more than one transactions
request for locking the same data item,
only one of them is granted the lock.
prevention
 One of the most popular deadlock
prevention methods is pre-acquisition of
all the locks. In this method, a
transaction acquires all the locks before
starting to execute and retains the locks
for the entire duration of transaction. If
another transaction needs any of the
already acquired locks, it has to wait until
all the locks it needs are available. Using
this approach, the system is prevented
from being deadlocked since none of the
waiting transactions are holding any lock.
Deadlock Avoidance
 The deadlock avoidance approach handles deadlocks
before they occur. It analyzes the transactions and the
locks to determine whether or not waiting leads to a
deadlock.
 The method can be briefly stated as follows.
Transactions start executing and request data items that
they need to lock. The lock manager checks whether
the lock is available. If it is available, the lock manager
allocates the data item and the transaction acquires the
lock.

 There are two algorithms for this purpose, namely wait-
die and wound-wait. Let us assume that there are two
transactions, T1 and T2, where T1 tries to lock a data
item which is already locked by T2. The algorithms are
as follows −
 Wait-Die − If T1 is older than T2, T1 is allowed to wait.
Otherwise, if T1 is younger than T2, T1 is aborted and
later restarted.
 Wound-Wait − If T1 is older than T2, T2 is aborted and
later restarted. Otherwise, if T1 is younger than T2, T1
is allowed to wait.
Deadlock Detection and
Removal
 The deadlock detection and
removal approach runs a deadlock
detect and removes deadlock in
case there is one.
Detection:
 If deadlock occur then identifying the prepresses and
recourses involved in deadlock.
Recovery:
ProcessTermination
 First of all get resources back and gain forward progress.
 Could delete all the resources which occur in deadlock.
 Delete one at a time until deadlock is broken is a time consuming.
 Delete the processor which consume the time during execution.
Failure and Faults of DDBMS
 Soft Failure
 Soft failure is the type of failure that causes the loss in
volatile memory of the computer and not in the
persistent storage. Operating system failure.
 Main memory crash.
 Transaction failure
 Failure of supporting software.
 Power failure.
Hard Failure
 A hard failure is the type of failure that causes loss of
data in the persistent or non-volatile storage like disk.
 Power failure.
 Faults in media.
 Read-write malfunction.
 Corruption of information on the disk.
 Read/write head crash of disk.
THE END

More Related Content

PPT
Deadlock management
PDF
Chapter 5 Database Transaction Management
PDF
management of distributed transactions
PPTX
Validation based protocol
PPT
Two phase commit protocol in dbms
PPT
Transaction
PPT
Transactions in dbms
PPTX
Recovery with concurrent transaction
Deadlock management
Chapter 5 Database Transaction Management
management of distributed transactions
Validation based protocol
Two phase commit protocol in dbms
Transaction
Transactions in dbms
Recovery with concurrent transaction

What's hot (20)

PPTX
Concurrency control!
PPTX
Transaction Management - Deadlock Handling
PPTX
2 phase locking protocol DBMS
PPTX
Concurrency control
PPTX
Demand paging
PPTX
Concurrency control
PPT
Unit 4 DBMS.ppt
PDF
Serializability
PPT
16. Concurrency Control in DBMS
PPTX
Transaction management DBMS
PPTX
serializability in dbms
PPTX
Segmentation in operating systems
PPTX
Page replacement algorithms
PPTX
Lock based protocols
PPTX
Multidimensional schema of data warehouse
PPTX
Concurrency control
PPTX
Concurrency Control in Database Management System
PDF
8 memory management strategies
PPTX
Operating system critical section
PPTX
Deadlock dbms
Concurrency control!
Transaction Management - Deadlock Handling
2 phase locking protocol DBMS
Concurrency control
Demand paging
Concurrency control
Unit 4 DBMS.ppt
Serializability
16. Concurrency Control in DBMS
Transaction management DBMS
serializability in dbms
Segmentation in operating systems
Page replacement algorithms
Lock based protocols
Multidimensional schema of data warehouse
Concurrency control
Concurrency Control in Database Management System
8 memory management strategies
Operating system critical section
Deadlock dbms
Ad

Similar to Deadlock in database (20)

PPT
Lecture 5 Deadlocks in Database Systems.ppt
PPTX
DistributedDeadlock on distriburtedNetwork.pptx
PPTX
deadlock handling
PPTX
Deadlock and shadow paging
PDF
Ijiret ashwini-kc-deadlock-detection-in-homogeneous-distributed-database-systems
PPTX
Unit iv: Deadlocks
PPTX
Deadlocks and Deadlock Detection Other Issues
PPTX
Deadlocks
PPTX
Concurrency Control & Deadlock Handling
PPSX
Deadlock ss
PPTX
Untitled presentation.pptx os ppt deadlock prevention
PPTX
Adbms 42 deadlocks and starvation
PPTX
Overview of Deadlock unit 3 part 1
PDF
Concurrency control
PPTX
operating system
PPTX
operating system
PPT
Deadlocks
Lecture 5 Deadlocks in Database Systems.ppt
DistributedDeadlock on distriburtedNetwork.pptx
deadlock handling
Deadlock and shadow paging
Ijiret ashwini-kc-deadlock-detection-in-homogeneous-distributed-database-systems
Unit iv: Deadlocks
Deadlocks and Deadlock Detection Other Issues
Deadlocks
Concurrency Control & Deadlock Handling
Deadlock ss
Untitled presentation.pptx os ppt deadlock prevention
Adbms 42 deadlocks and starvation
Overview of Deadlock unit 3 part 1
Concurrency control
operating system
operating system
Deadlocks
Ad

More from Tayyab Hussain (10)

PPTX
Networking devices
PPTX
Ipv6 presention
PPT
Introduction to SQL
PPTX
Input devices presentation
PPTX
Self discipline
PPT
Prejudice and stereotyping
PPT
Newtons law of motion
PPT
Generations of computers
PPTX
Topology
PPTX
Ipv6 presention
Networking devices
Ipv6 presention
Introduction to SQL
Input devices presentation
Self discipline
Prejudice and stereotyping
Newtons law of motion
Generations of computers
Topology
Ipv6 presention

Recently uploaded (20)

PPTX
Chapter 5: Probability Theory and Statistics
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Hybrid model detection and classification of lung cancer
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Chapter 5: Probability Theory and Statistics
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
TLE Review Electricity (Electricity).pptx
Hindi spoken digit analysis for native and non-native speakers
Module 1.ppt Iot fundamentals and Architecture
A novel scalable deep ensemble learning framework for big data classification...
Hybrid model detection and classification of lung cancer
A comparative study of natural language inference in Swahili using monolingua...
Getting started with AI Agents and Multi-Agent Systems
DP Operators-handbook-extract for the Mautical Institute
Assigned Numbers - 2025 - Bluetooth® Document
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
observCloud-Native Containerability and monitoring.pptx
OMC Textile Division Presentation 2021.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
cloud_computing_Infrastucture_as_cloud_p
WOOl fibre morphology and structure.pdf for textiles
NewMind AI Weekly Chronicles - August'25-Week II
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx

Deadlock in database

  • 2. Deadlock:  Deadlock is a state of a database system having two or more transactions, when each transaction is waiting for a data item that is being locked by some other transaction. A deadlock can be indicated by a cycle in the wait-for-graph. This is a directed graph in which the vertices denote transactions and the edges denote waits for data items.
  • 3. Example:  For example, in the following wait-for-graph, transaction T1 is waiting for data item X which is locked by T3. T3 is waiting for Y which is locked by T2 and T2 is waiting for Z which is locked by T1. Hence, a waiting cycle is formed, and none of the transactions can proceed executing.
  • 4. DEADLOCK HANDLING • when a deadlock occurs, different operating systems respond to them in different non- standard manners. • The Major approaches are as follows  IGNORING DEADLOCK  DETECTION
  • 5. IGNORING DEADLOCK In this approach, it is assumed that a deadlock will never occur. This is also an application of the Ostrich algorithm. This approach was initially used by MINIX and UNIX. This is used when the time intervals between occurrences of deadlocks are large and the data loss incurred each time is tolerable
  • 6. DETECTION  The deadlock detection and removal approach runs a deadlock detection algorithm periodically and removes deadlock in case there is one.
  • 7. Prevention:  The deadlock prevention approach does not allow any transaction to acquire locks that will lead to deadlocks. The convention is that when more than one transactions request for locking the same data item, only one of them is granted the lock.
  • 8. prevention  One of the most popular deadlock prevention methods is pre-acquisition of all the locks. In this method, a transaction acquires all the locks before starting to execute and retains the locks for the entire duration of transaction. If another transaction needs any of the already acquired locks, it has to wait until all the locks it needs are available. Using this approach, the system is prevented from being deadlocked since none of the waiting transactions are holding any lock.
  • 9. Deadlock Avoidance  The deadlock avoidance approach handles deadlocks before they occur. It analyzes the transactions and the locks to determine whether or not waiting leads to a deadlock.  The method can be briefly stated as follows. Transactions start executing and request data items that they need to lock. The lock manager checks whether the lock is available. If it is available, the lock manager allocates the data item and the transaction acquires the lock. 
  • 10.  There are two algorithms for this purpose, namely wait- die and wound-wait. Let us assume that there are two transactions, T1 and T2, where T1 tries to lock a data item which is already locked by T2. The algorithms are as follows −  Wait-Die − If T1 is older than T2, T1 is allowed to wait. Otherwise, if T1 is younger than T2, T1 is aborted and later restarted.  Wound-Wait − If T1 is older than T2, T2 is aborted and later restarted. Otherwise, if T1 is younger than T2, T1 is allowed to wait.
  • 11. Deadlock Detection and Removal  The deadlock detection and removal approach runs a deadlock detect and removes deadlock in case there is one.
  • 12. Detection:  If deadlock occur then identifying the prepresses and recourses involved in deadlock.
  • 13. Recovery: ProcessTermination  First of all get resources back and gain forward progress.  Could delete all the resources which occur in deadlock.  Delete one at a time until deadlock is broken is a time consuming.  Delete the processor which consume the time during execution.
  • 14. Failure and Faults of DDBMS  Soft Failure  Soft failure is the type of failure that causes the loss in volatile memory of the computer and not in the persistent storage. Operating system failure.  Main memory crash.  Transaction failure  Failure of supporting software.  Power failure.
  • 15. Hard Failure  A hard failure is the type of failure that causes loss of data in the persistent or non-volatile storage like disk.  Power failure.  Faults in media.  Read-write malfunction.  Corruption of information on the disk.  Read/write head crash of disk.