SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
Concurrency Control
Concurrency Control
n   Lock-Based Protocols
n   Timestamp-Based Protocols
n   Validation-Based Protocols
n   Deadlock Handling




                                 2
n   When several transactions execute
    concurrently in the database, the system
    must control the interaction among the
    concurrent transactions
n   This control is achieved through one of a
    variety of mechanisms called concurrency-
    control schemes



                                                3
Lock-Based Protocols
n   A lock is a mechanism to control concurrent access
    to a data item
n   Data items can be locked in two modes :
     1. exclusive (X) mode. Data item can be both read
    as well as written. X-lock is requested using lock-
    X instruction.
     2. shared (S) mode. Data item can only be read.
    S-lock is requested using lock-S instruction.
n   Lock requests are made to concurrency-control
    manager. Transaction can proceed only after
    request is granted.                              4
Timestamp-Based Protocols
n   Each transaction is issued a timestamp when it
    enters the system. If an old transaction Ti has
    time-stamp TS(Ti), a new transaction Tj is
    assigned time-stamp TS(Tj) such that TS(Ti)
    <TS(Tj).
n   The protocol manages concurrent execution
    such that the time-stamps determine the
    serializability order.
                                                      5
n   In order to assure such behavior, the protocol
    maintains for each data Q two timestamp
    values:
    n   W-timestamp(Q) is the largest time-stamp of
        any transaction that executed write(Q)
        successfully.
    n   R-timestamp(Q) is the largest time-stamp of any
        transaction that executed read(Q) successfully.


                                                      6
Validation-Based Protocol
n    Execution of transaction Ti is done in three phases.
    1. Read and execution phase: Transaction Ti
     writes only to
        temporary local variables
    2. Validation phase: Transaction Ti performs a
     ``validation test''
         to determine if local variables can be written
     without violating
         serializability.
    3. Write phase: If Ti is validated, the updates are
     applied to the
      database; otherwise, Ti is rolled back.
                                                       7
Deadlock Handling
n   System is deadlocked if there is a set of
    transactions such that every transaction in
    the set is waiting for another transaction in
    the set.




                                                    8
Deadlock Recovery
n   When deadlock is detected :
    n   Some transaction will have to rolled back (made a
        victim) to break deadlock. Select that transaction
        as victim that will incur minimum cost.
    n   Rollback -- determine how far to roll back
        transaction
         n   Total rollback: Abort the transaction and then restart it.
         n   More effective to roll back transaction only as far as
             necessary to break deadlock.
    n   Starvation happens if same transaction is always
        chosen as victim. Include the number of rollbacks
        in the cost factor to avoid starvation
                                                                     9

Weitere ähnliche Inhalte

Was ist angesagt?

Validation based protocol
Validation based protocolValidation based protocol
Validation based protocolBBDITM LUCKNOW
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocolsChethanMp7
 
Database ,11 Concurrency Control
Database ,11 Concurrency ControlDatabase ,11 Concurrency Control
Database ,11 Concurrency ControlAli Usman
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Meghaj Mallick
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency controlJaved Khan
 
Distributed concurrency control
Distributed concurrency controlDistributed concurrency control
Distributed concurrency controlBinte fatima
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management SystemJanki Shah
 
Locking base concurrency control
  Locking base concurrency control  Locking base concurrency control
Locking base concurrency controlPrakash Poudel
 
4. concurrency control
4. concurrency control4. concurrency control
4. concurrency controlAbDul ThaYyal
 
Deadlock Detection
Deadlock DetectionDeadlock Detection
Deadlock DetectionStuart Joy
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handlingSuraj Kumar
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMSkoolkampus
 
Databases: Concurrency Control
Databases: Concurrency ControlDatabases: Concurrency Control
Databases: Concurrency ControlDamian T. Gordon
 
Transactions (Distributed computing)
Transactions (Distributed computing)Transactions (Distributed computing)
Transactions (Distributed computing)Sri Prasanna
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing ConceptNishant Munjal
 

Was ist angesagt? (20)

Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Validation based protocol
Validation based protocolValidation based protocol
Validation based protocol
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocols
 
Database ,11 Concurrency Control
Database ,11 Concurrency ControlDatabase ,11 Concurrency Control
Database ,11 Concurrency Control
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency control
 
Distributed concurrency control
Distributed concurrency controlDistributed concurrency control
Distributed concurrency control
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
Locking base concurrency control
  Locking base concurrency control  Locking base concurrency control
Locking base concurrency control
 
4. concurrency control
4. concurrency control4. concurrency control
4. concurrency control
 
Unit 6
Unit 6Unit 6
Unit 6
 
Deadlock Detection
Deadlock DetectionDeadlock Detection
Deadlock Detection
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handling
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
Databases: Concurrency Control
Databases: Concurrency ControlDatabases: Concurrency Control
Databases: Concurrency Control
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
 
Serializability
SerializabilitySerializability
Serializability
 
Transactions (Distributed computing)
Transactions (Distributed computing)Transactions (Distributed computing)
Transactions (Distributed computing)
 
Distributed DBMS - Unit 9 - Distributed Deadlock & Recovery
Distributed DBMS - Unit 9 - Distributed Deadlock & RecoveryDistributed DBMS - Unit 9 - Distributed Deadlock & Recovery
Distributed DBMS - Unit 9 - Distributed Deadlock & Recovery
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing Concept
 

Andere mochten auch

Andere mochten auch (6)

Deadlocks1
Deadlocks1Deadlocks1
Deadlocks1
 
Deadlocks2
Deadlocks2Deadlocks2
Deadlocks2
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lock
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 

Ähnlich wie Concurrency Conrol

Concurrency control
Concurrency controlConcurrency control
Concurrency controlJaya Jeswani
 
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 & Deadlock Handling
Concurrency Control & Deadlock HandlingConcurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingMeghaj Mallick
 
Adbms 43 multiversion concurrency control
Adbms 43 multiversion concurrency controlAdbms 43 multiversion concurrency control
Adbms 43 multiversion concurrency controlVaibhav Khanna
 
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 note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdfBijayNag1
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptxPravinBhargav1
 
Transaction Management - Deadlock Handling
Transaction Management - Deadlock HandlingTransaction Management - Deadlock Handling
Transaction Management - Deadlock Handlingkavitha muneeshwaran
 
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptxVALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptxSamyakJain710491
 
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
 

Ähnlich wie Concurrency Conrol (20)

Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf a
 
Concurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingConcurrency Control & Deadlock Handling
Concurrency Control & Deadlock Handling
 
Transaction management
Transaction managementTransaction management
Transaction management
 
Adbms 43 multiversion concurrency control
Adbms 43 multiversion concurrency controlAdbms 43 multiversion concurrency control
Adbms 43 multiversion concurrency control
 
concurrency control
concurrency controlconcurrency control
concurrency control
 
Cs501 concurrency
Cs501 concurrencyCs501 concurrency
Cs501 concurrency
 
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 note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdf
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
Concurrency Control
Concurrency ControlConcurrency Control
Concurrency Control
 
Transaction Management - Deadlock Handling
Transaction Management - Deadlock HandlingTransaction Management - Deadlock Handling
Transaction Management - Deadlock Handling
 
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptxVALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
 
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...
 
Chapter18
Chapter18Chapter18
Chapter18
 
Dbms
DbmsDbms
Dbms
 

Mehr von lubna19

Programming in Oracle with PL/SQL
Programming in Oracle with PL/SQLProgramming in Oracle with PL/SQL
Programming in Oracle with PL/SQLlubna19
 
Normalization and Codd's Rule
Normalization and Codd's Rule Normalization and Codd's Rule
Normalization and Codd's Rule lubna19
 
ER Modelling
ER ModellingER Modelling
ER Modellinglubna19
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to databaselubna19
 
Security and Integrity
Security and IntegritySecurity and Integrity
Security and Integritylubna19
 

Mehr von lubna19 (6)

9
99
9
 
Programming in Oracle with PL/SQL
Programming in Oracle with PL/SQLProgramming in Oracle with PL/SQL
Programming in Oracle with PL/SQL
 
Normalization and Codd's Rule
Normalization and Codd's Rule Normalization and Codd's Rule
Normalization and Codd's Rule
 
ER Modelling
ER ModellingER Modelling
ER Modelling
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
Security and Integrity
Security and IntegritySecurity and Integrity
Security and Integrity
 

Concurrency Conrol

  • 2. Concurrency Control n Lock-Based Protocols n Timestamp-Based Protocols n Validation-Based Protocols n Deadlock Handling 2
  • 3. n When several transactions execute concurrently in the database, the system must control the interaction among the concurrent transactions n This control is achieved through one of a variety of mechanisms called concurrency- control schemes 3
  • 4. Lock-Based Protocols n A lock is a mechanism to control concurrent access to a data item n Data items can be locked in two modes : 1. exclusive (X) mode. Data item can be both read as well as written. X-lock is requested using lock- X instruction. 2. shared (S) mode. Data item can only be read. S-lock is requested using lock-S instruction. n Lock requests are made to concurrency-control manager. Transaction can proceed only after request is granted. 4
  • 5. Timestamp-Based Protocols n Each transaction is issued a timestamp when it enters the system. If an old transaction Ti has time-stamp TS(Ti), a new transaction Tj is assigned time-stamp TS(Tj) such that TS(Ti) <TS(Tj). n The protocol manages concurrent execution such that the time-stamps determine the serializability order. 5
  • 6. n In order to assure such behavior, the protocol maintains for each data Q two timestamp values: n W-timestamp(Q) is the largest time-stamp of any transaction that executed write(Q) successfully. n R-timestamp(Q) is the largest time-stamp of any transaction that executed read(Q) successfully. 6
  • 7. Validation-Based Protocol n Execution of transaction Ti is done in three phases. 1. Read and execution phase: Transaction Ti writes only to temporary local variables 2. Validation phase: Transaction Ti performs a ``validation test'' to determine if local variables can be written without violating serializability. 3. Write phase: If Ti is validated, the updates are applied to the database; otherwise, Ti is rolled back. 7
  • 8. Deadlock Handling n System is deadlocked if there is a set of transactions such that every transaction in the set is waiting for another transaction in the set. 8
  • 9. Deadlock Recovery n When deadlock is detected : n Some transaction will have to rolled back (made a victim) to break deadlock. Select that transaction as victim that will incur minimum cost. n Rollback -- determine how far to roll back transaction n Total rollback: Abort the transaction and then restart it. n More effective to roll back transaction only as far as necessary to break deadlock. n Starvation happens if same transaction is always chosen as victim. Include the number of rollbacks in the cost factor to avoid starvation 9