Movatterモバイル変換


[0]ホーム

URL:


JS
Uploaded byJanki Shah
PPTX, PDF20,704 views

Concurrency Control in Database Management System

The document discusses concurrency control in database management systems, focusing on lock-based protocols and strategies for handling deadlocks. It explains the mechanisms for obtaining and releasing locks, the two-phase locking protocol, and the risks of deadlock and starvation. Strategies for deadlock handling, including prevention, avoidance, and detection, are also outlined, highlighting specific rules like wait-die and wound-wait to manage resource allocation.

Embed presentation

Downloaded 574 times
Subject : Database Management SystemTopic : Concurrency Control
CONTENTS• What is Concurrency Control?• Lock Based Protocol• Two Phase Locking Protocol• Deadlock
What is Concurrency Control?The technique is used to protect data when multiple usersare accessing same data concurrently (same time) iscalled concurrency control
Lock Based Protocol• Lock is a mechanism to control concurrent access to dataitem• Data items can be locked in two modes:1) Exclusive (X) Mode :- Data item can be both read as well aswritten. X-lock is requested using lock-X instruction2) Shared (S) Mode :- Data item can only be read. S-lock isrequested using lock-S instruction• Lock requests are made to concurrency-control manager• Transaction can proceed only after request is granted
Lock Based Protocol• Lock-compatibility Matrix :S XS TRUE FALSEX FALSE FALSE• A transaction may be granted a lock on an item if therequested lock is compatible with locks already held on theitem by other transaction• Any number of transactions can hold shared locks on anitem, But if any transaction holds an exclusive on the itemno other transaction may hold any lock on the item
Lock Based Protocol• If a lock cannot be granted, the requesting transaction ismade to wait till all incompatible locks held by othertransaction have been released. The lock is then granted.• Example:T1: lock-S(A); // Grant-S(A,T1)read (A);unlock(A);lock-S(B); // Grant-S(B,T1)read (B);unlock(B);display(A+B)
Pitfalls of Lock Based Protocol• Locking as above is not sufficient to guarantee serializability -if A and B get updated in-between the read of A and B, thedisplayed sum would be wrong.• A locking protocol is a set of rules followed by all transactionswhile requesting and releasing locks. Locking protocols restrictthe set of possible schedules.
Pitfalls of Lock Based Protocol• Neither T3 nor T4 can make progress — executing lock-S(B)causes T4 to wait for T3 to release its lock on B, while executinglock-X(A) causes T3 to wait for T4 to release its lock on A.• Such a situation is called a deadlock.– To handle a deadlock one of T3 or T4 must be rolled backand its locks released.
Pitfalls of Lock Based Protocol• Starvation is also possible if concurrency control manager isbadly designed. For example:– A transaction may be waiting for an X-lock on an item, whilea sequence of other transactions request and are granted anS-lock on the same item.– The same transaction is repeatedly rolled back due todeadlocks.• Concurrency control manager can be designed to preventstarvation.
Two Phase Locking Protocol• This is a protocol which ensures conflict-serializable schedules.• Phase 1: Growing Phase– transaction may obtain locks– transaction may not release locks• Phase 2: Shrinking Phase– transaction may release locks– transaction may not obtain locks• The protocol assures serializability. It can be proved that thetransactions can be serialized in the order of their lock points(i.e. the point where a transaction acquired its final lock).
Two Phase Locking Protocol• Two-phase locking does not ensure freedom from deadlocks• Cascading roll-back is possible under two-phase locking. Toavoid this, follow a modified protocol called strict two-phaselocking. Here a transaction must hold all its exclusive locks tillit commits/aborts.• Rigorous two-phase locking is even stricter: here all locks areheld till commit/abort. In this protocol transactions can beserialized in the order in which they commit.
Deadlock•A set of processes is deadlocked if each process in the set iswaiting for an event that only another process in the set cancause.Ti Tj
Four Conditions for DeadlockA. Mutual exclusion condition– each resource assigned to 1 process or is availableB. Hold and wait condition– process holding resources can request additionalC. No preemption condition– previously granted resources cannot forcibly taken awayD. Circular wait condition– must be a circular chain of 2 or more processes– each is waiting for resource held by next member of the chain
Strategies of Deadlock Handling•Deadlock prevention.Prevents deadlocks by restraining requests made to ensurethat at least one of the four deadlock conditions cannot occur.•Deadlock avoidance.Dynamically grants a resource to a process if the resultingstate is safe. A state is safe if there is at least one executionsequence that allows all processes to run to completion.•Deadlock detection and recovery.That Allows deadlocks to form; then finds and breaks them.
Deadlock AvoidanceWAIT-DIE Rule :If Ti requests a lock on a data item which is already lockedby Tj , then Ti is permitted to wait if ts (Ti ) < ts (Tj ). Ifts (Ti ) >ts (Tj ) , then Ti is aborted and restarted with the same timestamp.– if ts (Ti ) <ts (Tj ) then Ti waits else Ti dies– non-preemptive: Ti never preempts Tj– prefers younger transactions
Deadlock AvoidanceWOUND-WAIT Rule :If Ti requests a lock on a data item which is already lockedby Tj , then Ti is permitted to wait iff ts(Ti)>ts(Tj). Ifts(Ti)<ts(Tj), then Tj is aborted and the lock is granted to Ti.– if ts(Ti)<ts(Tj) then Tj is wounded else Ti waits– preemptive: Ti preempts Tj if it is younger– prefers older transactions
Deadlock Detection• For deadlock detection, the system must provide– An algorithm that examines the state of the system to detect whether adeadlock has occurred– And an algorithm to recover from the deadlock• A detection-and-recovery scheme requires various kinds ofoverhead– Run-time costs of maintaining necessary information and executing thedetection algorithm
Concurrency Control in Database Management System

Recommended

PPT
15. Transactions in DBMS
PPTX
Deadlock in database
PPTX
Concurrency control
PPT
16. Concurrency Control in DBMS
PPTX
Concurrency control
PPTX
2 phase locking protocol DBMS
PPTX
Deadlock dbms
PPTX
Concurrency control
PPT
17. Recovery System in DBMS
PPTX
serializability in dbms
PPTX
Lock based protocols
PPTX
Transactions and Concurrency Control
PPTX
Process synchronization in Operating Systems
PPTX
Integrity Constraints
PPTX
Transaction management DBMS
PPT
File organization 1
PPTX
Demand Paging in OS (Operating System): Example, Advantages, Working
PPTX
PPT
Computer architecture pipelining
PPTX
Data structure - Graph
PPTX
deadlock handling
PPTX
Integrity Constraints
PPTX
Acid properties
PPTX
Timestamp protocols
PPTX
Log based and Recovery with concurrent transaction
PPTX
Trigger
PDF
Serializability
PPTX
Overview of Concurrency Control & Recovery in Distributed Databases
PPTX
concurrency control
PPTX
Concurrency control

More Related Content

PPT
15. Transactions in DBMS
PPTX
Deadlock in database
PPTX
Concurrency control
PPT
16. Concurrency Control in DBMS
PPTX
Concurrency control
PPTX
2 phase locking protocol DBMS
PPTX
Deadlock dbms
PPTX
Concurrency control
15. Transactions in DBMS
Deadlock in database
Concurrency control
16. Concurrency Control in DBMS
Concurrency control
2 phase locking protocol DBMS
Deadlock dbms
Concurrency control

What's hot

PPT
17. Recovery System in DBMS
PPTX
serializability in dbms
PPTX
Lock based protocols
PPTX
Transactions and Concurrency Control
PPTX
Process synchronization in Operating Systems
PPTX
Integrity Constraints
PPTX
Transaction management DBMS
PPT
File organization 1
PPTX
Demand Paging in OS (Operating System): Example, Advantages, Working
PPTX
PPT
Computer architecture pipelining
PPTX
Data structure - Graph
PPTX
deadlock handling
PPTX
Integrity Constraints
PPTX
Acid properties
PPTX
Timestamp protocols
PPTX
Log based and Recovery with concurrent transaction
PPTX
Trigger
PDF
Serializability
PPTX
Overview of Concurrency Control & Recovery in Distributed Databases
17. Recovery System in DBMS
serializability in dbms
Lock based protocols
Transactions and Concurrency Control
Process synchronization in Operating Systems
Integrity Constraints
Transaction management DBMS
File organization 1
Demand Paging in OS (Operating System): Example, Advantages, Working
Computer architecture pipelining
Data structure - Graph
deadlock handling
Integrity Constraints
Acid properties
Timestamp protocols
Log based and Recovery with concurrent transaction
Trigger
Serializability
Overview of Concurrency Control & Recovery in Distributed Databases

Similar to Concurrency Control in Database Management System

PPTX
concurrency control
PPTX
Concurrency control
PPTX
BCT 2312 - Chapter 3 - Concurrency Control Techniques in DBMSs.pptx
PPTX
Concurrency control PPT
PDF
PPT-concurrency Control database management system DBMS concurrent control (U...
PPTX
CHapter four database managementm04.pptx
PPT
concurrency-control
PPTX
Concurrency Control in Databases.Database management systems
PDF
Concurrency Control in Database Management System
PPTX
Module-5_DataBase Management System.pptx
PDF
Cs501 concurrency
PPT
Chapter18
PPTX
Concurrency Control & Deadlock Handling
PPTX
Transaction and NOSQL Chapter-Module 5.pptx
PDF
Concurrency Control, Recovery, Case Studies
PPT
deadlock and locking - dbms
PPT
Database management system chapter16
PDF
Design & Development of an Advanced Database Management System Using Multiver...
PDF
F017213747
concurrency control
Concurrency control
BCT 2312 - Chapter 3 - Concurrency Control Techniques in DBMSs.pptx
Concurrency control PPT
PPT-concurrency Control database management system DBMS concurrent control (U...
CHapter four database managementm04.pptx
concurrency-control
Concurrency Control in Databases.Database management systems
Concurrency Control in Database Management System
Module-5_DataBase Management System.pptx
Cs501 concurrency
Chapter18
Concurrency Control & Deadlock Handling
Transaction and NOSQL Chapter-Module 5.pptx
Concurrency Control, Recovery, Case Studies
deadlock and locking - dbms
Database management system chapter16
Design & Development of an Advanced Database Management System Using Multiver...
F017213747

More from Janki Shah

PPTX
Collections in .net technology (2160711)
PPTX
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
PPTX
File Management in Operating System
PPT
Addressing in Computer Networks
PPTX
Queue in Data Structure
PPTX
Number system in Digital Electronics
PPTX
Exception Handling in object oriented programming using C++
PPTX
Compiler in System Programming/Code Optimization techniques in System Program...
PPT
Sorting in Linear Time in Analysis & Design of Algorithm
Collections in .net technology (2160711)
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
File Management in Operating System
Addressing in Computer Networks
Queue in Data Structure
Number system in Digital Electronics
Exception Handling in object oriented programming using C++
Compiler in System Programming/Code Optimization techniques in System Program...
Sorting in Linear Time in Analysis & Design of Algorithm

Recently uploaded

PPTX
Washing-Machine-Simulation-using-PICSimLab.pptx
PPTX
TRANSPORTATION ENGINEERING Unit-5.1.pptx
PDF
HEV Descriptive Questions https://www.slideshare.net/slideshow/hybrid-electr...
PDF
ANPARA THERMAL POWER STATION[1] sangam.pdf
PPTX
introduction-to-maintenance- Dr. Munthear Alqaderi
PPTX
2-Photoelectric effect, phenomena and its related concept.pptx
PPTX
Planning and selection of equipment for different mining conditions. Equipmen...
PPTX
unit-1 Data structure (3).pptx Data structure And Algorithms
PDF
The Impact of Telework on Urban Development (www.kiu.ac.ug)
PDF
Workshop practice theory course (Unit-1) By Varun Pratap Singh.pdf
PDF
Event #3_ Build a Gemini Bot, Together with GitHub_private.pdf
PDF
Reinforced Earth Walls Notes .pdf
PPTX
Ship Repair and fault diagnosis and restoration of system back to normal .pptx
PDF
Chemical Bonding _ Class Notes.pdf for jee
PDF
IPE 105 - Engineering Materials Constitution of Alloys
PPTX
Bio engineering and production of energy through biomass.pptx
PDF
ghvjvhhvkjvgiyvicitiychjnlnokigytdcesdftyhuiookjhygvcrxesdcftyjiokoloihtfcxsx...
PPTX
Supercapacitor.pptx...............................
PDF
OOPCodesjavapracticalkabirpawarpptinparacticalexamination
PPT
Virtual Instrumentation Programming Techniques.ppt
Washing-Machine-Simulation-using-PICSimLab.pptx
TRANSPORTATION ENGINEERING Unit-5.1.pptx
HEV Descriptive Questions https://www.slideshare.net/slideshow/hybrid-electr...
ANPARA THERMAL POWER STATION[1] sangam.pdf
introduction-to-maintenance- Dr. Munthear Alqaderi
2-Photoelectric effect, phenomena and its related concept.pptx
Planning and selection of equipment for different mining conditions. Equipmen...
unit-1 Data structure (3).pptx Data structure And Algorithms
The Impact of Telework on Urban Development (www.kiu.ac.ug)
Workshop practice theory course (Unit-1) By Varun Pratap Singh.pdf
Event #3_ Build a Gemini Bot, Together with GitHub_private.pdf
Reinforced Earth Walls Notes .pdf
Ship Repair and fault diagnosis and restoration of system back to normal .pptx
Chemical Bonding _ Class Notes.pdf for jee
IPE 105 - Engineering Materials Constitution of Alloys
Bio engineering and production of energy through biomass.pptx
ghvjvhhvkjvgiyvicitiychjnlnokigytdcesdftyhuiookjhygvcrxesdcftyjiokoloihtfcxsx...
Supercapacitor.pptx...............................
OOPCodesjavapracticalkabirpawarpptinparacticalexamination
Virtual Instrumentation Programming Techniques.ppt
In this document
Powered by AI

Introduction to Database Management System focusing on Concurrency Control, explaining its role and contents covered in the presentation.

Defining Concurrency Control as a technique for protecting data during concurrent access by multiple users.

Discusses the Lock Based Protocol, types of locks (Exclusive, Shared), compatibility, and examples demonstrating lock requests.

Identifies pitfalls such as deadlocks and starvation in Lock Based Protocols, providing examples and solutions for improvement.

Details of the Two Phase Locking Protocol ensuring conflict-serializability schedules, along with conditions regarding locks.

Defines deadlock in process management and outlines the four necessary conditions for a deadlock to occur.

Explains strategies for dealing with deadlocks including prevention, avoidance, detection, and recovery methods.

Concurrency Control in Database Management System

  • 1.
    Subject : DatabaseManagement SystemTopic : Concurrency Control
  • 2.
    CONTENTS• What isConcurrency Control?• Lock Based Protocol• Two Phase Locking Protocol• Deadlock
  • 3.
    What is ConcurrencyControl?The technique is used to protect data when multiple usersare accessing same data concurrently (same time) iscalled concurrency control
  • 5.
    Lock Based Protocol•Lock is a mechanism to control concurrent access to dataitem• Data items can be locked in two modes:1) Exclusive (X) Mode :- Data item can be both read as well aswritten. X-lock is requested using lock-X instruction2) Shared (S) Mode :- Data item can only be read. S-lock isrequested using lock-S instruction• Lock requests are made to concurrency-control manager• Transaction can proceed only after request is granted
  • 6.
    Lock Based Protocol•Lock-compatibility Matrix :S XS TRUE FALSEX FALSE FALSE• A transaction may be granted a lock on an item if therequested lock is compatible with locks already held on theitem by other transaction• Any number of transactions can hold shared locks on anitem, But if any transaction holds an exclusive on the itemno other transaction may hold any lock on the item
  • 7.
    Lock Based Protocol•If a lock cannot be granted, the requesting transaction ismade to wait till all incompatible locks held by othertransaction have been released. The lock is then granted.• Example:T1: lock-S(A); // Grant-S(A,T1)read (A);unlock(A);lock-S(B); // Grant-S(B,T1)read (B);unlock(B);display(A+B)
  • 8.
    Pitfalls of LockBased Protocol• Locking as above is not sufficient to guarantee serializability -if A and B get updated in-between the read of A and B, thedisplayed sum would be wrong.• A locking protocol is a set of rules followed by all transactionswhile requesting and releasing locks. Locking protocols restrictthe set of possible schedules.
  • 9.
    Pitfalls of LockBased Protocol• Neither T3 nor T4 can make progress — executing lock-S(B)causes T4 to wait for T3 to release its lock on B, while executinglock-X(A) causes T3 to wait for T4 to release its lock on A.• Such a situation is called a deadlock.– To handle a deadlock one of T3 or T4 must be rolled backand its locks released.
  • 10.
    Pitfalls of LockBased Protocol• Starvation is also possible if concurrency control manager isbadly designed. For example:– A transaction may be waiting for an X-lock on an item, whilea sequence of other transactions request and are granted anS-lock on the same item.– The same transaction is repeatedly rolled back due todeadlocks.• Concurrency control manager can be designed to preventstarvation.
  • 12.
    Two Phase LockingProtocol• This is a protocol which ensures conflict-serializable schedules.• Phase 1: Growing Phase– transaction may obtain locks– transaction may not release locks• Phase 2: Shrinking Phase– transaction may release locks– transaction may not obtain locks• The protocol assures serializability. It can be proved that thetransactions can be serialized in the order of their lock points(i.e. the point where a transaction acquired its final lock).
  • 13.
    Two Phase LockingProtocol• Two-phase locking does not ensure freedom from deadlocks• Cascading roll-back is possible under two-phase locking. Toavoid this, follow a modified protocol called strict two-phaselocking. Here a transaction must hold all its exclusive locks tillit commits/aborts.• Rigorous two-phase locking is even stricter: here all locks areheld till commit/abort. In this protocol transactions can beserialized in the order in which they commit.
  • 15.
    Deadlock•A set ofprocesses is deadlocked if each process in the set iswaiting for an event that only another process in the set cancause.Ti Tj
  • 16.
    Four Conditions forDeadlockA. Mutual exclusion condition– each resource assigned to 1 process or is availableB. Hold and wait condition– process holding resources can request additionalC. No preemption condition– previously granted resources cannot forcibly taken awayD. Circular wait condition– must be a circular chain of 2 or more processes– each is waiting for resource held by next member of the chain
  • 17.
    Strategies of DeadlockHandling•Deadlock prevention.Prevents deadlocks by restraining requests made to ensurethat at least one of the four deadlock conditions cannot occur.•Deadlock avoidance.Dynamically grants a resource to a process if the resultingstate is safe. A state is safe if there is at least one executionsequence that allows all processes to run to completion.•Deadlock detection and recovery.That Allows deadlocks to form; then finds and breaks them.
  • 18.
    Deadlock AvoidanceWAIT-DIE Rule:If Ti requests a lock on a data item which is already lockedby Tj , then Ti is permitted to wait if ts (Ti ) < ts (Tj ). Ifts (Ti ) >ts (Tj ) , then Ti is aborted and restarted with the same timestamp.– if ts (Ti ) <ts (Tj ) then Ti waits else Ti dies– non-preemptive: Ti never preempts Tj– prefers younger transactions
  • 19.
    Deadlock AvoidanceWOUND-WAIT Rule:If Ti requests a lock on a data item which is already lockedby Tj , then Ti is permitted to wait iff ts(Ti)>ts(Tj). Ifts(Ti)<ts(Tj), then Tj is aborted and the lock is granted to Ti.– if ts(Ti)<ts(Tj) then Tj is wounded else Ti waits– preemptive: Ti preempts Tj if it is younger– prefers older transactions
  • 20.
    Deadlock Detection• Fordeadlock detection, the system must provide– An algorithm that examines the state of the system to detect whether adeadlock has occurred– And an algorithm to recover from the deadlock• A detection-and-recovery scheme requires various kinds ofoverhead– Run-time costs of maintaining necessary information and executing thedetection algorithm

[8]ページ先頭

©2009-2025 Movatter.jp