SlideShare une entreprise Scribd logo
1  sur  12
3. Concurrency Control
▪ Pessimistic concurrency control
Check before a database operation is executed by locking data
items before they are read and written or checking timestamps.
▪ Optimistic concurrency control
Transactions are allowed to proceed freely in the private work
space before committing it is validated.
Once validated, the objects may be updated in updating phase.
3. Concurrency Control
▪ Locking techniques for concurrency control
☞ Locking data items is one of the main techniques used for controlling
the concurrent execution of transactions.
☞ A lock describes the status of the data item with respect to possible
operations that can be applied to that item.
- Used for synchronizing the access by concurrent transactions to the
database items.
☞ When an object is locked by another transaction
- The requesting transaction must wait.
3. Concurrency Control
▪ Types of Locks
1) Binary locks
☞ Only two states:
locked (lock_item(x) operation)
unlocked (unlock_item(x) operation) (or 1 and 0, for simplicity)
☞ A distinct lock is associated with each database item x.
If the value of the lock on x is 1, item x cannot be accessed by a
database operation that requests the item.
If the value of the lock on x is 0, the item can be accessed when
requested. We refer to the current value (or state) of the lock
associated with item x as lock(x).
3. Concurrency Control
▪ Types of Locks
1) Binary locks
☞ Two operations, lock_ and unlock_item are used with binary locking.
Lock_item(x):
- requests access to an item x by first issuing a lock_item(x) operation.
If lock(x) = 1, the transaction is forced to wait.
If lock(x) = 0, it is set to 1 and the transaction is allowed to access item x.
Unlock_item (x):
- when using the item, it issues an unlock_item(x) operation.
- which sets lock(x) to 0 (unlocks the item) so that x may be accessed by
other transactions.
☞ Hence, a binary lock enforces mutual exclusion on the data item ;
= i.e., at a time only one transaction can hold a lock.
3. Concurrency Control
▪ Types of Lock
2) Certify lock
☞ Used to improving performance of locking protocols.
3) Conversion of locks
☞ A transaction that already holds a lock on item x is allowed under
certain conditions to convert the lock from one locked state to another.
Ex) it is possible for a transaction t to issue a read_lock(x) and then
later on to upgrade the lock by issuing a write_lock(x) operation.
• Upgrading:
• Downgrading:
3. Concurrency Control
▪ Locks don’t guarantee serialisability: lost update

♪. Schedule 1: t1 followed by t2
♪. Schedule 2: t2 followed by t1

x=50, y=80
x=70, y=50
3. Concurrency Control
▪ Non-serialisable schedule s that uses locks
Let x=20, y=30.

Result of s

x=50, y=50.
3. Concurrency Control
▪ Ensuring serialisability: two-phase locking
• All locking operations (read_lock, write_lock) precede the first unlock
operation in the transactions.

• Two phases:
Expanding phase:
- new locks on items can be acquired but none can be released.
Shrinking phase:
- existing locks can be released but no new ones can be acquired.
3. Concurrency Control
▪ Ensuring serialisability: two-phase locking
• All locking operations (read_lock, write_lock) precede the first unlock
operation in the transactions.

• Two phases:
Expanding phase:
- new locks on items can be acquired but none can be released.
Shrinking phase:
- existing locks can be released but no new ones can be acquired.
3. Concurrency Control
▪ Two-phase locking(TPL)
• Basic 2pl
When a transaction releases a lock, it may not request another lock.
3. Concurrency Control
▪ Locking problems: deadlock
Each of two or more transactions is waiting for the other to release an item.
Also called a deadly embrace.

To handle a deadlock one of t3 or t4 must be rolled back and its locks
released.
The potential for deadlock exists in most locking protocols.
Deadlocks are a necessary evil.
3. Concurrency Control
▪ Starvation
If concurrency control manager is badly designed.
Ex)
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.
The same transaction is repeatedly rolled back due to deadlocks.
Concurrency control manager can be designed to prevent starvation.

Contenu connexe

Similaire à 2 con control

Chapter Three _Concurrency Control Techniques_ETU.ppt
Chapter Three _Concurrency Control Techniques_ETU.pptChapter Three _Concurrency Control Techniques_ETU.ppt
Chapter Three _Concurrency Control Techniques_ETU.ppt
haymanot taddesse
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
Christalin Nelson
 

Similaire à 2 con control (20)

Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
concurrency control
concurrency controlconcurrency control
concurrency control
 
Chapter Three _Concurrency Control Techniques_ETU.ppt
Chapter Three _Concurrency Control Techniques_ETU.pptChapter Three _Concurrency Control Techniques_ETU.ppt
Chapter Three _Concurrency Control Techniques_ETU.ppt
 
Dbms
DbmsDbms
Dbms
 
Concurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingConcurrency Control & Deadlock Handling
Concurrency Control & Deadlock Handling
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Chapter18
Chapter18Chapter18
Chapter18
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
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 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
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
 
Concurrency control!
Concurrency control!Concurrency control!
Concurrency control!
 
Concurrency Control
Concurrency ControlConcurrency Control
Concurrency Control
 
Concurrency note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdf
 
concurrency-control-techniques.ppt
concurrency-control-techniques.pptconcurrency-control-techniques.ppt
concurrency-control-techniques.ppt
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocols
 
Unit 5 rdbms study_material
Unit 5  rdbms study_materialUnit 5  rdbms study_material
Unit 5 rdbms study_material
 

Plus de Mr Patrick NIYISHAKA (20)

Summary
SummarySummary
Summary
 
3 summary
3 summary3 summary
3 summary
 
2 ddb architecture
2 ddb architecture2 ddb architecture
2 ddb architecture
 
1 ddb
1 ddb1 ddb
1 ddb
 
2 countermeasures
2 countermeasures2 countermeasures
2 countermeasures
 
2 countermeasures
2 countermeasures2 countermeasures
2 countermeasures
 
3 summary
3 summary3 summary
3 summary
 
1 db security
1 db security1 db security
1 db security
 
4 summary
4 summary4 summary
4 summary
 
3 summary
3 summary3 summary
3 summary
 
1 con exe
1 con exe1 con exe
1 con exe
 
1 basic concepts
1 basic concepts1 basic concepts
1 basic concepts
 
2 recovery
2 recovery2 recovery
2 recovery
 
3 transaction
3 transaction3 transaction
3 transaction
 
3 summary
3 summary3 summary
3 summary
 
1 query processing
1 query processing1 query processing
1 query processing
 
1 query processing
1 query processing1 query processing
1 query processing
 
2 optimization
2 optimization2 optimization
2 optimization
 
2 collision
2 collision2 collision
2 collision
 
4 summary
4 summary4 summary
4 summary
 

Dernier

The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
daisycvs
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
allensay1
 
Mckinsey foundation level Handbook for Viewing
Mckinsey foundation level Handbook for ViewingMckinsey foundation level Handbook for Viewing
Mckinsey foundation level Handbook for Viewing
Nauman Safdar
 

Dernier (20)

Arti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdfArti Languages Pre Seed Teaser Deck 2024.pdf
Arti Languages Pre Seed Teaser Deck 2024.pdf
 
Berhampur Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Berhampur Call Girl Just Call 8084732287 Top Class Call Girl Service AvailableBerhampur Call Girl Just Call 8084732287 Top Class Call Girl Service Available
Berhampur Call Girl Just Call 8084732287 Top Class Call Girl Service Available
 
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Falcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business PotentialFalcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business Potential
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business Growth
 
HomeRoots Pitch Deck | Investor Insights | April 2024
HomeRoots Pitch Deck | Investor Insights | April 2024HomeRoots Pitch Deck | Investor Insights | April 2024
HomeRoots Pitch Deck | Investor Insights | April 2024
 
New 2024 Cannabis Edibles Investor Pitch Deck Template
New 2024 Cannabis Edibles Investor Pitch Deck TemplateNew 2024 Cannabis Edibles Investor Pitch Deck Template
New 2024 Cannabis Edibles Investor Pitch Deck Template
 
Kalyan Call Girl 98350*37198 Call Girls in Escort service book now
Kalyan Call Girl 98350*37198 Call Girls in Escort service book nowKalyan Call Girl 98350*37198 Call Girls in Escort service book now
Kalyan Call Girl 98350*37198 Call Girls in Escort service book now
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
 
Berhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGBerhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
 
Pre Engineered Building Manufacturers Hyderabad.pptx
Pre Engineered  Building Manufacturers Hyderabad.pptxPre Engineered  Building Manufacturers Hyderabad.pptx
Pre Engineered Building Manufacturers Hyderabad.pptx
 
PARK STREET 💋 Call Girl 9827461493 Call Girls in Escort service book now
PARK STREET 💋 Call Girl 9827461493 Call Girls in  Escort service book nowPARK STREET 💋 Call Girl 9827461493 Call Girls in  Escort service book now
PARK STREET 💋 Call Girl 9827461493 Call Girls in Escort service book now
 
Mckinsey foundation level Handbook for Viewing
Mckinsey foundation level Handbook for ViewingMckinsey foundation level Handbook for Viewing
Mckinsey foundation level Handbook for Viewing
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptx
 
WheelTug Short Pitch Deck 2024 | Byond Insights
WheelTug Short Pitch Deck 2024 | Byond InsightsWheelTug Short Pitch Deck 2024 | Byond Insights
WheelTug Short Pitch Deck 2024 | Byond Insights
 
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1
 
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGBerhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
 

2 con control

  • 1. 3. Concurrency Control ▪ Pessimistic concurrency control Check before a database operation is executed by locking data items before they are read and written or checking timestamps. ▪ Optimistic concurrency control Transactions are allowed to proceed freely in the private work space before committing it is validated. Once validated, the objects may be updated in updating phase.
  • 2. 3. Concurrency Control ▪ Locking techniques for concurrency control ☞ Locking data items is one of the main techniques used for controlling the concurrent execution of transactions. ☞ A lock describes the status of the data item with respect to possible operations that can be applied to that item. - Used for synchronizing the access by concurrent transactions to the database items. ☞ When an object is locked by another transaction - The requesting transaction must wait.
  • 3. 3. Concurrency Control ▪ Types of Locks 1) Binary locks ☞ Only two states: locked (lock_item(x) operation) unlocked (unlock_item(x) operation) (or 1 and 0, for simplicity) ☞ A distinct lock is associated with each database item x. If the value of the lock on x is 1, item x cannot be accessed by a database operation that requests the item. If the value of the lock on x is 0, the item can be accessed when requested. We refer to the current value (or state) of the lock associated with item x as lock(x).
  • 4. 3. Concurrency Control ▪ Types of Locks 1) Binary locks ☞ Two operations, lock_ and unlock_item are used with binary locking. Lock_item(x): - requests access to an item x by first issuing a lock_item(x) operation. If lock(x) = 1, the transaction is forced to wait. If lock(x) = 0, it is set to 1 and the transaction is allowed to access item x. Unlock_item (x): - when using the item, it issues an unlock_item(x) operation. - which sets lock(x) to 0 (unlocks the item) so that x may be accessed by other transactions. ☞ Hence, a binary lock enforces mutual exclusion on the data item ; = i.e., at a time only one transaction can hold a lock.
  • 5. 3. Concurrency Control ▪ Types of Lock 2) Certify lock ☞ Used to improving performance of locking protocols. 3) Conversion of locks ☞ A transaction that already holds a lock on item x is allowed under certain conditions to convert the lock from one locked state to another. Ex) it is possible for a transaction t to issue a read_lock(x) and then later on to upgrade the lock by issuing a write_lock(x) operation. • Upgrading: • Downgrading:
  • 6. 3. Concurrency Control ▪ Locks don’t guarantee serialisability: lost update ♪. Schedule 1: t1 followed by t2 ♪. Schedule 2: t2 followed by t1 x=50, y=80 x=70, y=50
  • 7. 3. Concurrency Control ▪ Non-serialisable schedule s that uses locks Let x=20, y=30. Result of s x=50, y=50.
  • 8. 3. Concurrency Control ▪ Ensuring serialisability: two-phase locking • All locking operations (read_lock, write_lock) precede the first unlock operation in the transactions. • Two phases: Expanding phase: - new locks on items can be acquired but none can be released. Shrinking phase: - existing locks can be released but no new ones can be acquired.
  • 9. 3. Concurrency Control ▪ Ensuring serialisability: two-phase locking • All locking operations (read_lock, write_lock) precede the first unlock operation in the transactions. • Two phases: Expanding phase: - new locks on items can be acquired but none can be released. Shrinking phase: - existing locks can be released but no new ones can be acquired.
  • 10. 3. Concurrency Control ▪ Two-phase locking(TPL) • Basic 2pl When a transaction releases a lock, it may not request another lock.
  • 11. 3. Concurrency Control ▪ Locking problems: deadlock Each of two or more transactions is waiting for the other to release an item. Also called a deadly embrace. To handle a deadlock one of t3 or t4 must be rolled back and its locks released. The potential for deadlock exists in most locking protocols. Deadlocks are a necessary evil.
  • 12. 3. Concurrency Control ▪ Starvation If concurrency control manager is badly designed. Ex) 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. The same transaction is repeatedly rolled back due to deadlocks. Concurrency control manager can be designed to prevent starvation.