SlideShare une entreprise Scribd logo
1  sur  17
R.Pavithra,
II-MSc(IT),
Nadar saraswathi college of arts and science,
Theni.
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 users
are accessing same data concurrently(same time) is called
concurrency control.
Lock Based Protocol
o Lock is a mechanism to control concurrent access to data
item
o Data items can be locked in two modes:
a. Exclusive(X)Mode: Data item can be both read as well
as written. X-lock is request using lock-X instruction.
b. Shared (S) mode: data item can only be read,S-lock is
request using lock-s instruction.
o Lock request are made to concurrency-control manger.
o Transaction can proceed only after request s grated.
Cont……..
 Lock-compatibility matrix:
 A transaction may be granted a lock on
an item if the requested lock is
compatible with locks already held on
the item by other transaction.
 Any number of transaction can hold
shared locks on an item , but if any
transaction holds an exclusive on the
item no other transaction may hold any
lock on the item.
s x
s true
fals
e
x fals
e
fals
e
Cont……..
 A transaction may be granted a lock on an item if the
requested lock is compatible with locks already held
on the item by other transaction.
 Any number of transaction can hold shared locks on
an item , but if any transaction holds an exclusive on
the item no other transaction may hold any lock on
the item.
Cont…….
 If a lock cannot be granted , the requesting transaction is
made to wait till all incompatible locks held by other
transaction 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
serialializability- if A and B get in between the read of A and B
,the displayed sum would be wrong.
 A locking protocol is a set of rules followed by all transactions
while requesting and releasing locks . Locking protocols
restrict the set of possible schedules.
T3 T4
Lock-x(B)
Read(B)
B:=B – 50
Write(B)
Lock-X(A)
Lock-S(A)
Read(A)
Lock-S(B)
Cont….
 Neither T₃ nor T₄ can make progress –executing lock-S(B) causes T₄ to
wait for T₃ to release its lock on B , while executing lock-X(A) causes T₃
to wait for T₄ to relase its lock on A.
 To handle a deadlock one of T₃ or T₄ must be rolled back
and its locks relased.
 Starvation is also possible if concurrency control manager
is badly designed. For example:
I. A transaction may be waiting for an X –lock on an item
,while a sequence of other transactions request and are
granted an S-lock on the same item.
II. The same transaction is repeatedly rolled back due to
deadlocks.
 Concurrency control manager can be designed to prevent
starvation.
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
the transaction can be serialized in the order of their lock
points.
(i.e, the point where a transaction acquired its final lock).
Cont….
 Two –phase locking does not ensure from deadlocks.
 Cascading roll-back is possible under two-phase locking.
To avoid this, follow a modifed protocol called strict two-
phase locking. Here a transaction must hold all its
exclusive locks till it commits/aborts.
 Rigorous two-phase locking is even stricter: here all
locks are held till commit/abort. In this protocol
transaction can be serialized in the order in which they
commit.
DEADLOCK
 A set of process is deadlock if each process in the set is
waiting for an event that only another process in the set can
cause.
Four conditions for deadlock
 Mutual exclusive condition
-each resource assigned to 1 process or is available
 Hold and wait condition
-process holding resources can request additional
 No preeption condition
-previously granted resoures cannot forcibly taken away
 Circular wait condition
-must be a circular chain of 2 or more process
-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 ensure
that at least one of the deadlock conditions cannot occur.
• Deadlock avoidance:
Dynamically grants a resource to a process if the resulting
state is safe. A state is safe if there is at least one execution
sequence that allows all process to run to completion.
• Deadlock detection and recovery:
That allows dealocks to form; then finds and breaks them.
Deadlock avoidance
 WAIT- DIE RULE:
if Tᵢ request a lock on a data
item which is already locked
by Tʲ, then Tᵢ is permitted to
wait if ts (Tᵢ)<ts(Tʲ). If ts
(Tᵢ)>ts(Tʲ), then Tᵢ is aborted
and restarted with the same time
stamp.
-if ts (Tᵢ)<ts(Tʲ) then Tᵢ waits
else Tᵢ dies
-non-preempting: Tᵢ never
preempts Tʲ
-prefers younger transactions
 WOUND-WAIT RULE:
If Tᵢ request a lock on a data
item which is already locked by
Tʲ, then Tᵢ is permitted to wait if
ts (Tᵢ)>ts(Tʲ). If ts (Tᵢ)<ts(Tʲ),
then Tʲ is aborted and the lock is
granted to Tᵢ.
-if ts (Tᵢ)<ts(Tʲ) then Tʲ is
wounded else Tᵢ waits
- preemptive : Tᵢ preempts Tʲ 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 a deadlock has occurred
 And an algorithm to recover from the deadlock
A detection-and –recovery scheme require various kinds of
overhead
 Runtime –time costs of maintaining necessary information and
executing the detection algorithm.
concurrency control

Contenu connexe

Tendances

Deadlock Detection
Deadlock DetectionDeadlock Detection
Deadlock DetectionStuart Joy
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control TechniquesRaj vardhan
 
Concurrency control
Concurrency controlConcurrency control
Concurrency controlvarsha singh
 
Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013Prosanta Ghosh
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management SystemJanki Shah
 
Deadlock management
Deadlock managementDeadlock management
Deadlock managementAhmed kasim
 
Concurrency control
Concurrency controlConcurrency control
Concurrency controlJaya Jeswani
 
Timestamp based protocol
Timestamp based protocolTimestamp based protocol
Timestamp based protocolVincent Chu
 
Database ,11 Concurrency Control
Database ,11 Concurrency ControlDatabase ,11 Concurrency Control
Database ,11 Concurrency ControlAli Usman
 
Lock Interface in Java
Lock Interface in JavaLock Interface in Java
Lock Interface in JavaHome
 
Java reentrant lock tutorial by jeetendra mandal
Java reentrant lock tutorial by jeetendra mandalJava reentrant lock tutorial by jeetendra mandal
Java reentrant lock tutorial by jeetendra mandaljeetendra mandal
 
Sequence detector for "111"
Sequence detector for "111"Sequence detector for "111"
Sequence detector for "111"Omkar Rane
 

Tendances (20)

Deadlock Detection
Deadlock DetectionDeadlock Detection
Deadlock Detection
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control Techniques
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Cs501 concurrency
Cs501 concurrencyCs501 concurrency
Cs501 concurrency
 
Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013Dbms ii mca-ch10-concurrency-control-2013
Dbms ii mca-ch10-concurrency-control-2013
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
 
Unit 6
Unit 6Unit 6
Unit 6
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 
Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
 
Deadlock in dbms
Deadlock in dbmsDeadlock in dbms
Deadlock in dbms
 
Deadlock management
Deadlock managementDeadlock management
Deadlock management
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Deadlock in database
Deadlock in databaseDeadlock in database
Deadlock in database
 
Timestamp based protocol
Timestamp based protocolTimestamp based protocol
Timestamp based protocol
 
Database ,11 Concurrency Control
Database ,11 Concurrency ControlDatabase ,11 Concurrency Control
Database ,11 Concurrency Control
 
Lock Interface in Java
Lock Interface in JavaLock Interface in Java
Lock Interface in Java
 
Java reentrant lock tutorial by jeetendra mandal
Java reentrant lock tutorial by jeetendra mandalJava reentrant lock tutorial by jeetendra mandal
Java reentrant lock tutorial by jeetendra mandal
 
Sequence detector for "111"
Sequence detector for "111"Sequence detector for "111"
Sequence detector for "111"
 

Similaire à concurrency control

Concurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingConcurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingMeghaj Mallick
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptxVijaySourtha
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptxPravinBhargav1
 
Unit 5 rdbms study_material
Unit 5  rdbms study_materialUnit 5  rdbms study_material
Unit 5 rdbms study_materialgayaramesh
 
Concurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesConcurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesPrabu U
 
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 control
Concurrency  controlConcurrency  control
Concurrency controlJaved Khan
 
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
 
deadlock and locking - dbms
deadlock and locking -  dbmsdeadlock and locking -  dbms
deadlock and locking - dbmsSurya Swaroop
 
Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...IOSR Journals
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf aMdAyanParwez
 

Similaire à concurrency control (20)

Concurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingConcurrency Control & Deadlock Handling
Concurrency Control & Deadlock Handling
 
Ch16
Ch16Ch16
Ch16
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptx
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
 
Unit 5 rdbms study_material
Unit 5  rdbms study_materialUnit 5  rdbms study_material
Unit 5 rdbms study_material
 
Chapter18
Chapter18Chapter18
Chapter18
 
Concurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case StudiesConcurrency Control, Recovery, Case Studies
Concurrency Control, Recovery, Case Studies
 
Dbms
DbmsDbms
Dbms
 
2 con control
2 con control2 con control
2 con control
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
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 control
Concurrency  controlConcurrency  control
Concurrency control
 
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
 
deadlock and locking - dbms
deadlock and locking -  dbmsdeadlock and locking -  dbms
deadlock and locking - dbms
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
F017213747
F017213747F017213747
F017213747
 
F017213747
F017213747F017213747
F017213747
 
Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf a
 

Plus de rajshreemuthiah (20)

oracle
oracleoracle
oracle
 
quality
qualityquality
quality
 
bigdata
bigdatabigdata
bigdata
 
polymorphism
polymorphismpolymorphism
polymorphism
 
solutions and understanding text analytics
solutions and understanding text analyticssolutions and understanding text analytics
solutions and understanding text analytics
 
interface
interfaceinterface
interface
 
Testing &ampdebugging
Testing &ampdebuggingTesting &ampdebugging
Testing &ampdebugging
 
Education
EducationEducation
Education
 
Formal verification
Formal verificationFormal verification
Formal verification
 
Transaction management
Transaction management Transaction management
Transaction management
 
Multi thread
Multi threadMulti thread
Multi thread
 
System testing
System testingSystem testing
System testing
 
software maintenance
software maintenancesoftware maintenance
software maintenance
 
exception handling
exception handlingexception handling
exception handling
 
e governance
e governancee governance
e governance
 
recovery management
recovery managementrecovery management
recovery management
 
Implementing polymorphism
Implementing polymorphismImplementing polymorphism
Implementing polymorphism
 
Buffer managements
Buffer managementsBuffer managements
Buffer managements
 
os linux
os linuxos linux
os linux
 
Ipv4
Ipv4Ipv4
Ipv4
 

Dernier

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

concurrency control

  • 1. R.Pavithra, II-MSc(IT), Nadar saraswathi college of arts and science, Theni. CONCURRENCY CONTROL
  • 2. CONTENTS  What is concurrency control?  Lock based protocol  Two phase locking protocol  deadlock
  • 3. What is concurrency control?  The technique is used to protect data when multiple users are accessing same data concurrently(same time) is called concurrency control.
  • 4. Lock Based Protocol o Lock is a mechanism to control concurrent access to data item o Data items can be locked in two modes: a. Exclusive(X)Mode: Data item can be both read as well as written. X-lock is request using lock-X instruction. b. Shared (S) mode: data item can only be read,S-lock is request using lock-s instruction. o Lock request are made to concurrency-control manger. o Transaction can proceed only after request s grated.
  • 5. Cont……..  Lock-compatibility matrix:  A transaction may be granted a lock on an item if the requested lock is compatible with locks already held on the item by other transaction.  Any number of transaction can hold shared locks on an item , but if any transaction holds an exclusive on the item no other transaction may hold any lock on the item. s x s true fals e x fals e fals e
  • 6. Cont……..  A transaction may be granted a lock on an item if the requested lock is compatible with locks already held on the item by other transaction.  Any number of transaction can hold shared locks on an item , but if any transaction holds an exclusive on the item no other transaction may hold any lock on the item.
  • 7. Cont…….  If a lock cannot be granted , the requesting transaction is made to wait till all incompatible locks held by other transaction 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 lock based protocol  Locking as above is not sufficient to guarantee serialializability- if A and B get in between the read of A and B ,the displayed sum would be wrong.  A locking protocol is a set of rules followed by all transactions while requesting and releasing locks . Locking protocols restrict the set of possible schedules. T3 T4 Lock-x(B) Read(B) B:=B – 50 Write(B) Lock-X(A) Lock-S(A) Read(A) Lock-S(B)
  • 9. Cont….  Neither T₃ nor T₄ can make progress –executing lock-S(B) causes T₄ to wait for T₃ to release its lock on B , while executing lock-X(A) causes T₃ to wait for T₄ to relase its lock on A.  To handle a deadlock one of T₃ or T₄ must be rolled back and its locks relased.  Starvation is also possible if concurrency control manager is badly designed. For example: I. A transaction may be waiting for an X –lock on an item ,while a sequence of other transactions request and are granted an S-lock on the same item. II. The same transaction is repeatedly rolled back due to deadlocks.  Concurrency control manager can be designed to prevent starvation.
  • 10. 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 the transaction can be serialized in the order of their lock points. (i.e, the point where a transaction acquired its final lock).
  • 11. Cont….  Two –phase locking does not ensure from deadlocks.  Cascading roll-back is possible under two-phase locking. To avoid this, follow a modifed protocol called strict two- phase locking. Here a transaction must hold all its exclusive locks till it commits/aborts.  Rigorous two-phase locking is even stricter: here all locks are held till commit/abort. In this protocol transaction can be serialized in the order in which they commit.
  • 12. DEADLOCK  A set of process is deadlock if each process in the set is waiting for an event that only another process in the set can cause.
  • 13. Four conditions for deadlock  Mutual exclusive condition -each resource assigned to 1 process or is available  Hold and wait condition -process holding resources can request additional  No preeption condition -previously granted resoures cannot forcibly taken away  Circular wait condition -must be a circular chain of 2 or more process -each is waiting for resource held by next member of the chain
  • 14. Strategies of deadlock handling  Deadlock prevention: prevents deadlocks by restraining requests made to ensure that at least one of the deadlock conditions cannot occur. • Deadlock avoidance: Dynamically grants a resource to a process if the resulting state is safe. A state is safe if there is at least one execution sequence that allows all process to run to completion. • Deadlock detection and recovery: That allows dealocks to form; then finds and breaks them.
  • 15. Deadlock avoidance  WAIT- DIE RULE: if Tᵢ request a lock on a data item which is already locked by Tʲ, then Tᵢ is permitted to wait if ts (Tᵢ)<ts(Tʲ). If ts (Tᵢ)>ts(Tʲ), then Tᵢ is aborted and restarted with the same time stamp. -if ts (Tᵢ)<ts(Tʲ) then Tᵢ waits else Tᵢ dies -non-preempting: Tᵢ never preempts Tʲ -prefers younger transactions  WOUND-WAIT RULE: If Tᵢ request a lock on a data item which is already locked by Tʲ, then Tᵢ is permitted to wait if ts (Tᵢ)>ts(Tʲ). If ts (Tᵢ)<ts(Tʲ), then Tʲ is aborted and the lock is granted to Tᵢ. -if ts (Tᵢ)<ts(Tʲ) then Tʲ is wounded else Tᵢ waits - preemptive : Tᵢ preempts Tʲ if it is younger -prefers older transactions
  • 16. Deadlock detection For deadlock detection, the system must provide:  An algorithm that examines the state of the system to detect whether a deadlock has occurred  And an algorithm to recover from the deadlock A detection-and –recovery scheme require various kinds of overhead  Runtime –time costs of maintaining necessary information and executing the detection algorithm.