SlideShare a Scribd company logo
1 of 12
DATABASE MANAGEMENT
SYSTEM:
T WO PHASE LOCKING PROTOCOL
1 7 0 4 1 0 1 0 7 0 2 7
D H A N A N J AY S I N H J H A L A
S Y C E - I B AT C H B
INDEX
• Locks
• Locking protocols
• 2 phase locking protocol
–Phases
–Merits
–demerits
LOCKS
To ensure serializability, it is required that data items should be
accessed in mutual exclusive manner, i.e. if one transaction is accessing
a data item, no other transaction can modify that data item.
To implement this requirement locks are used.
A transaction is allowed to access a data item only if it is currently
holding a lock on that item.
There are 2 modes in which a data item may be locked:
Shared mode: if a transaction T1 has obtained a shared mode lock on
item Q, then T1 can read, but cannot write Q. it is denoted by S.
Exclusive: if a transaction T1 has obtained a exclusive mode lock on
item Q, then T1 can read & also write Q. it is denoted by X.
LOCKING PROTOCOLS
When a transaction requests a lock on a data item in a particular mode
and no other transaction has a lock on the same data item, the lock can
be granted.
Supposing a transaction T1 requests a lock on data item Q in a particular
mode M, the concurrency control manager grants the lock provided that
There is no other transaction holding a lock on Q in a mode that
conflicts with M
There is no other transaction that is waiting for a lock on Q, and that
made its lock request before T1.
2 PHASE LOCKING PROTOCOL
• This protocol requires that each transaction issue lock and
unlock requests in two phases:
– Growing phase: in this phase, a transaction may obtain locks, but
may not release any lock.
– Shrinking phase: in this phase, a transaction may release locks, but
may not obtain any new locks.
– Initially, a transaction is in the growing phase. The transaction
acquires locks as needed. Once a transaction releases a lock, it enters
in the shrinking phase and it cannot issue more lock requests.
2 PHASE LOCKING PROTOCOL
• E.g. Transaction given below is a two phase transaction.
• T3:
– lock X(B);
– read(B);
– B:= B-50;
– write(B);
– lock X(A);
– read(A);
– A:=A+50;
– write(A);
– unlock(B);
– unlock(A);
MERITS OF 2 PHASE LOCKING PROTOCOL
• The two phase locking protocol ensure conflict serializability.
• Consider any transaction, the point in the schedule where the
transaction has obtained it's final lock is called the lock point
of the transaction.
• Now, transaction can be ordered according to their lock
points. This ordering is a serializability ordering for the
transactions.
DEMERITS OF 2 PHASE LOCKING PROTOCOL
• The two phase locking protocol Does not ensure freedom from
deadlock:
– Consider the schedule shown in figure
– Transaction T3 and T4 are two phases but they are deadlocked.
• Cascading rollback may occur under two phase locking:
– Consider the schedule shown in figure
• As shown in the above figure transactions T5,T6 and T7 are
two phase, but failure of T5 after the read(A) instruction of T7
leads to cascading rollback of T6 and T7.
• Cascading rollback can be avoided by modification of two
phase locking:
– 1. Strict two phase locking protocol: This protocol requires that
locking should be two phase and all executive mode locks taken by a
transaction should be held until the transaction commits. This
requirement prevents any transaction from reading the data written
by any uncommitted transaction under exclusive mode until the
transaction commits.
• 2. The rigorous two phase locking protocol: This protocol
requires that all locks be held until the transaction commits.
2 phase locking protocol DBMS

More Related Content

What's hot

Multithreading
MultithreadingMultithreading
MultithreadingA B Shinde
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMSkoolkampus
 
Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating systemAli Haider
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency ControlDilum Bandara
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMSkoolkampus
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency controlJaved Khan
 
Multiversion Concurrency Control Techniques
Multiversion Concurrency Control TechniquesMultiversion Concurrency Control Techniques
Multiversion Concurrency Control TechniquesRaj vardhan
 
Distributed database management system
Distributed database management  systemDistributed database management  system
Distributed database management systemPooja Dixit
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMSkoolkampus
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-SystemsVenkata Sreeram
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)Ravinder Kamboj
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Treekhabbab_h
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control TechniquesRaj vardhan
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMSkoolkampus
 

What's hot (20)

Multithreading
MultithreadingMultithreading
Multithreading
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMS
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 
Operating System: Deadlock
Operating System: DeadlockOperating System: Deadlock
Operating System: Deadlock
 
DBMS - RAID
DBMS - RAIDDBMS - RAID
DBMS - RAID
 
Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency control
 
Multiversion Concurrency Control Techniques
Multiversion Concurrency Control TechniquesMultiversion Concurrency Control Techniques
Multiversion Concurrency Control Techniques
 
Distributed database management system
Distributed database management  systemDistributed database management  system
Distributed database management system
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Serializability
SerializabilitySerializability
Serializability
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control Techniques
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 

Similar to 2 phase locking protocol DBMS

Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyPritishMajumdar3
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyPritishMajumdar3
 
Concurrency Management
Concurrency ManagementConcurrency Management
Concurrency ManagementSURBHI SAROHA
 
Concurrency control
Concurrency controlConcurrency control
Concurrency controlJaya Jeswani
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptxPravinBhargav1
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf aMdAyanParwez
 
Concurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesConcurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesPrabu U
 
Variations Of Two Phase Locking
Variations Of Two Phase LockingVariations Of Two Phase Locking
Variations Of Two Phase LockingMohammed Twaha
 
db unit 4 dbms protocols in transaction
db unit 4 dbms  protocols in transactiondb unit 4 dbms  protocols in transaction
db unit 4 dbms protocols in transactionKumari Naveen
 
Concurrency note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdfBijayNag1
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptxVijaySourtha
 
recoverability and serializability dbms
recoverability and serializability  dbmsrecoverability and serializability  dbms
recoverability and serializability dbmsKumari Naveen
 

Similar to 2 phase locking protocol DBMS (20)

Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovely
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovely
 
Concurrency Management
Concurrency ManagementConcurrency Management
Concurrency Management
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
 
Cs501 concurrency
Cs501 concurrencyCs501 concurrency
Cs501 concurrency
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf a
 
Unit 5 dbms
Unit 5 dbmsUnit 5 dbms
Unit 5 dbms
 
Dbms
DbmsDbms
Dbms
 
Concurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesConcurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case Studies
 
concurrency control
concurrency controlconcurrency control
concurrency control
 
Variations Of Two Phase Locking
Variations Of Two Phase LockingVariations Of Two Phase Locking
Variations Of Two Phase Locking
 
Concurrency control
Concurrency control Concurrency control
Concurrency control
 
Concurrency Control
Concurrency ControlConcurrency Control
Concurrency Control
 
db unit 4 dbms protocols in transaction
db unit 4 dbms  protocols in transactiondb unit 4 dbms  protocols in transaction
db unit 4 dbms protocols in transaction
 
Concurrency note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdf
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptx
 
recoverability and serializability dbms
recoverability and serializability  dbmsrecoverability and serializability  dbms
recoverability and serializability dbms
 
2 con control
2 con control2 con control
2 con control
 

More from Dhananjaysinh Jhala

JavaScript own objects(Web Technology)
JavaScript own objects(Web Technology)JavaScript own objects(Web Technology)
JavaScript own objects(Web Technology)Dhananjaysinh Jhala
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guidelineDhananjaysinh Jhala
 
BCD arithmetic and 16-bit data operations
BCD arithmetic and 16-bit data operationsBCD arithmetic and 16-bit data operations
BCD arithmetic and 16-bit data operationsDhananjaysinh Jhala
 
applications of first order non linear partial differential equation
applications of first order non linear partial differential equationapplications of first order non linear partial differential equation
applications of first order non linear partial differential equationDhananjaysinh Jhala
 
variable entered map digital electronics
variable entered map digital electronicsvariable entered map digital electronics
variable entered map digital electronicsDhananjaysinh Jhala
 
Parabola, hyperbola and its applications
Parabola, hyperbola and its applicationsParabola, hyperbola and its applications
Parabola, hyperbola and its applicationsDhananjaysinh Jhala
 
1st, 2nd kind improper integrals
1st, 2nd kind improper integrals 1st, 2nd kind improper integrals
1st, 2nd kind improper integrals Dhananjaysinh Jhala
 
Earthing, grounding and isolation
Earthing, grounding and isolation Earthing, grounding and isolation
Earthing, grounding and isolation Dhananjaysinh Jhala
 

More from Dhananjaysinh Jhala (20)

Food donation project report II
Food donation project report IIFood donation project report II
Food donation project report II
 
Food donation project report I
Food donation project report IFood donation project report I
Food donation project report I
 
JavaScript own objects(Web Technology)
JavaScript own objects(Web Technology)JavaScript own objects(Web Technology)
JavaScript own objects(Web Technology)
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guideline
 
BCD arithmetic and 16-bit data operations
BCD arithmetic and 16-bit data operationsBCD arithmetic and 16-bit data operations
BCD arithmetic and 16-bit data operations
 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Sleeping barber problem
Sleeping barber problemSleeping barber problem
Sleeping barber problem
 
Email and DNS
Email and DNSEmail and DNS
Email and DNS
 
Friend function OOPC
Friend function OOPCFriend function OOPC
Friend function OOPC
 
applications of first order non linear partial differential equation
applications of first order non linear partial differential equationapplications of first order non linear partial differential equation
applications of first order non linear partial differential equation
 
concepts of national income
concepts of national income concepts of national income
concepts of national income
 
Circular Queue data structure
Circular Queue data structureCircular Queue data structure
Circular Queue data structure
 
variable entered map digital electronics
variable entered map digital electronicsvariable entered map digital electronics
variable entered map digital electronics
 
Dark sensor using photodiode
Dark sensor using photodiodeDark sensor using photodiode
Dark sensor using photodiode
 
Parabola, hyperbola and its applications
Parabola, hyperbola and its applicationsParabola, hyperbola and its applications
Parabola, hyperbola and its applications
 
1st, 2nd kind improper integrals
1st, 2nd kind improper integrals 1st, 2nd kind improper integrals
1st, 2nd kind improper integrals
 
Corporate life and skills
Corporate life and skillsCorporate life and skills
Corporate life and skills
 
type1,2 superconductors
type1,2 superconductors type1,2 superconductors
type1,2 superconductors
 
Earthing, grounding and isolation
Earthing, grounding and isolation Earthing, grounding and isolation
Earthing, grounding and isolation
 

Recently uploaded

AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxpritamlangde
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...ppkakm
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...gragchanchal546
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...ronahami
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesRashidFaridChishti
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 

Recently uploaded (20)

AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 

2 phase locking protocol DBMS

  • 1. DATABASE MANAGEMENT SYSTEM: T WO PHASE LOCKING PROTOCOL 1 7 0 4 1 0 1 0 7 0 2 7 D H A N A N J AY S I N H J H A L A S Y C E - I B AT C H B
  • 2. INDEX • Locks • Locking protocols • 2 phase locking protocol –Phases –Merits –demerits
  • 3. LOCKS To ensure serializability, it is required that data items should be accessed in mutual exclusive manner, i.e. if one transaction is accessing a data item, no other transaction can modify that data item. To implement this requirement locks are used. A transaction is allowed to access a data item only if it is currently holding a lock on that item. There are 2 modes in which a data item may be locked: Shared mode: if a transaction T1 has obtained a shared mode lock on item Q, then T1 can read, but cannot write Q. it is denoted by S. Exclusive: if a transaction T1 has obtained a exclusive mode lock on item Q, then T1 can read & also write Q. it is denoted by X.
  • 4. LOCKING PROTOCOLS When a transaction requests a lock on a data item in a particular mode and no other transaction has a lock on the same data item, the lock can be granted. Supposing a transaction T1 requests a lock on data item Q in a particular mode M, the concurrency control manager grants the lock provided that There is no other transaction holding a lock on Q in a mode that conflicts with M There is no other transaction that is waiting for a lock on Q, and that made its lock request before T1.
  • 5. 2 PHASE LOCKING PROTOCOL • This protocol requires that each transaction issue lock and unlock requests in two phases: – Growing phase: in this phase, a transaction may obtain locks, but may not release any lock. – Shrinking phase: in this phase, a transaction may release locks, but may not obtain any new locks. – Initially, a transaction is in the growing phase. The transaction acquires locks as needed. Once a transaction releases a lock, it enters in the shrinking phase and it cannot issue more lock requests.
  • 6. 2 PHASE LOCKING PROTOCOL • E.g. Transaction given below is a two phase transaction. • T3: – lock X(B); – read(B); – B:= B-50; – write(B); – lock X(A); – read(A); – A:=A+50; – write(A); – unlock(B); – unlock(A);
  • 7. MERITS OF 2 PHASE LOCKING PROTOCOL • The two phase locking protocol ensure conflict serializability. • Consider any transaction, the point in the schedule where the transaction has obtained it's final lock is called the lock point of the transaction. • Now, transaction can be ordered according to their lock points. This ordering is a serializability ordering for the transactions.
  • 8. DEMERITS OF 2 PHASE LOCKING PROTOCOL • The two phase locking protocol Does not ensure freedom from deadlock: – Consider the schedule shown in figure – Transaction T3 and T4 are two phases but they are deadlocked.
  • 9. • Cascading rollback may occur under two phase locking: – Consider the schedule shown in figure
  • 10. • As shown in the above figure transactions T5,T6 and T7 are two phase, but failure of T5 after the read(A) instruction of T7 leads to cascading rollback of T6 and T7. • Cascading rollback can be avoided by modification of two phase locking: – 1. Strict two phase locking protocol: This protocol requires that locking should be two phase and all executive mode locks taken by a transaction should be held until the transaction commits. This requirement prevents any transaction from reading the data written by any uncommitted transaction under exclusive mode until the transaction commits.
  • 11. • 2. The rigorous two phase locking protocol: This protocol requires that all locks be held until the transaction commits.