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

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

More Related Content

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

What's hot

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

Similar to Concurrency Control in Database Management System

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

More from Janki Shah

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

Recently uploaded

PPTX
Blockchain and cryptography Lecture Notes
PPTX
TRANSPORTATION ENGINEERING Unit-5.1.pptx
PPTX
Control Structures and Looping Basics Understanding Control Flow and Loops Co...
PPTX
unit-1 Data structure (3).pptx Data structure And Algorithms
PPTX
State Space Model of DC-DC Boost Converter
PPTX
Mc25104 - data structures and algorithms using PYTHON OOP_Python_Lecture_Note...
PPTX
introduction-to-maintenance- Dr. Munthear Alqaderi
PPTX
Intrusion Detection Systems presentation.pptx
PPTX
neural-networks-intro-basic-engineering.pptx
PPTX
Computer engineering for collage studen. pptx
PPTX
DevFest Seattle 2025 - AI Native Design Patterns.pptx
PDF
OOPCodesjavapracticalkabirpawarpptinparacticalexamination
PDF
Chemical Bonding _ Class Notes.pdf for jee
PPTX
Supercapacitor.pptx...............................
PDF
Soil Permeability and Seepage-Irrigation Structures
PDF
application of matrix in computer science
PDF
Welcome to ISPR 2026 - 12th International Conference on Image and Signal Pro...
PPTX
waste to energy deck v.3.pptx changing garbage to electricity
PPTX
31.03.24 - 7.CURRICULUM & TEACHING - LEARNING PROCESS IMPLEMENTATION DETAILS....
PPTX
Waste to Energy - G2 Ethanol.pptx to process
Blockchain and cryptography Lecture Notes
TRANSPORTATION ENGINEERING Unit-5.1.pptx
Control Structures and Looping Basics Understanding Control Flow and Loops Co...
unit-1 Data structure (3).pptx Data structure And Algorithms
State Space Model of DC-DC Boost Converter
Mc25104 - data structures and algorithms using PYTHON OOP_Python_Lecture_Note...
introduction-to-maintenance- Dr. Munthear Alqaderi
Intrusion Detection Systems presentation.pptx
neural-networks-intro-basic-engineering.pptx
Computer engineering for collage studen. pptx
DevFest Seattle 2025 - AI Native Design Patterns.pptx
OOPCodesjavapracticalkabirpawarpptinparacticalexamination
Chemical Bonding _ Class Notes.pdf for jee
Supercapacitor.pptx...............................
Soil Permeability and Seepage-Irrigation Structures
application of matrix in computer science
Welcome to ISPR 2026 - 12th International Conference on Image and Signal Pro...
waste to energy deck v.3.pptx changing garbage to electricity
31.03.24 - 7.CURRICULUM & TEACHING - LEARNING PROCESS IMPLEMENTATION DETAILS....
Waste to Energy - G2 Ethanol.pptx to process
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