SlideShare a Scribd company logo
3
Most read
4
Most read
5
Most read
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 (20)

PPTX
Lock based protocols
ChethanMp7
 
PPTX
Concurrency Control in Database Management System
Janki Shah
 
PPT
15. Transactions in DBMS
koolkampus
 
PPTX
serializability in dbms
Saranya Natarajan
 
PPTX
Concurrency control
Soumyajit Dutta
 
PPTX
Integrity Constraints
madhav bansal
 
PPTX
Transaction management DBMS
Megha Patel
 
PPTX
Concurrency Control in Distributed Database.
Meghaj Mallick
 
PPTX
Validation based protocol
BBDITM LUCKNOW
 
PPTX
Query processing in Distributed Database System
Meghaj Mallick
 
PDF
Normalization in DBMS
Hitesh Mohapatra
 
PPTX
Distributed dbms architectures
Pooja Dixit
 
PPT
Databases: Locking Methods
Damian T. Gordon
 
PPTX
ACID Property in DBMS
Techtud Network
 
PPT
File organization 1
Rupali Rana
 
PPT
16. Concurrency Control in DBMS
koolkampus
 
PPTX
1.4 data independence
BHARATH KUMAR
 
PPTX
The Relational Database Model
Shishir Aryal
 
PPTX
Database , 12 Reliability
Ali Usman
 
PDF
Serializability
Pyingkodi Maran
 
Lock based protocols
ChethanMp7
 
Concurrency Control in Database Management System
Janki Shah
 
15. Transactions in DBMS
koolkampus
 
serializability in dbms
Saranya Natarajan
 
Concurrency control
Soumyajit Dutta
 
Integrity Constraints
madhav bansal
 
Transaction management DBMS
Megha Patel
 
Concurrency Control in Distributed Database.
Meghaj Mallick
 
Validation based protocol
BBDITM LUCKNOW
 
Query processing in Distributed Database System
Meghaj Mallick
 
Normalization in DBMS
Hitesh Mohapatra
 
Distributed dbms architectures
Pooja Dixit
 
Databases: Locking Methods
Damian T. Gordon
 
ACID Property in DBMS
Techtud Network
 
File organization 1
Rupali Rana
 
16. Concurrency Control in DBMS
koolkampus
 
1.4 data independence
BHARATH KUMAR
 
The Relational Database Model
Shishir Aryal
 
Database , 12 Reliability
Ali Usman
 
Serializability
Pyingkodi Maran
 

Similar to 2 phase locking protocol DBMS (20)

PDF
Concurrency Control in Database Management System
SwarnimBajra
 
PPTX
Concurrency Control in Databases.Database management systems
ambikavenkatesh2
 
PPT
concurrency-control
Saranya Natarajan
 
PDF
Cs501 concurrency
Kamal Singh Lodhi
 
PPTX
CHapter four database managementm04.pptx
meharikiros2
 
DOCX
Concurrency Control Techniques
Raj vardhan
 
PPTX
Transaction Management in Database Processing
Sigit Priyanta
 
PPTX
Adbms 41 transaction control techniques
Vaibhav Khanna
 
PDF
Concurrency Control in Database Management system
Christalin Nelson
 
PDF
Module 5 part-2 concurrency control in dbms
barekaresahana
 
PPTX
BCT 2312 - Chapter 3 - Concurrency Control Techniques in DBMSs.pptx
gikurujoseph53
 
PPTX
transaction management-database management system
SheebaS25
 
PPTX
Unit 6
Abha Damani
 
PPTX
Transaction.pptx
ujjwalmatoliya
 
PPTX
concurrency control
rajshreemuthiah
 
PPTX
DBMS Pravin concurrency control technique.pptx
PravinBhargav1
 
PPT
Chapter 4 Concrruncy controling techniques (1).ppt
binaboss24
 
DOCX
Locking base concurrency control
Prakash Poudel
 
PPTX
Unit 5 dbms
Sweta Singh
 
PPTX
DBMS Presentation.pptx
PravinBhargav1
 
Concurrency Control in Database Management System
SwarnimBajra
 
Concurrency Control in Databases.Database management systems
ambikavenkatesh2
 
concurrency-control
Saranya Natarajan
 
Cs501 concurrency
Kamal Singh Lodhi
 
CHapter four database managementm04.pptx
meharikiros2
 
Concurrency Control Techniques
Raj vardhan
 
Transaction Management in Database Processing
Sigit Priyanta
 
Adbms 41 transaction control techniques
Vaibhav Khanna
 
Concurrency Control in Database Management system
Christalin Nelson
 
Module 5 part-2 concurrency control in dbms
barekaresahana
 
BCT 2312 - Chapter 3 - Concurrency Control Techniques in DBMSs.pptx
gikurujoseph53
 
transaction management-database management system
SheebaS25
 
Unit 6
Abha Damani
 
Transaction.pptx
ujjwalmatoliya
 
concurrency control
rajshreemuthiah
 
DBMS Pravin concurrency control technique.pptx
PravinBhargav1
 
Chapter 4 Concrruncy controling techniques (1).ppt
binaboss24
 
Locking base concurrency control
Prakash Poudel
 
Unit 5 dbms
Sweta Singh
 
DBMS Presentation.pptx
PravinBhargav1
 
Ad

More from Dhananjaysinh Jhala (20)

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

Recently uploaded (20)

PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PDF
smart lot access control system with eye
rasabzahra
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPT
Electrical Safety Presentation for Basics Learning
AliJaved79382
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
smart lot access control system with eye
rasabzahra
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Electrical Safety Presentation for Basics Learning
AliJaved79382
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 

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.