SlideShare una empresa de Scribd logo
1 de 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.

Más contenido relacionado

Similar a 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
 

Similar a 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
 

Más 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
 

Último

Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
daisycvs
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
lizamodels9
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
dlhescort
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
amitlee9823
 
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Anamikakaur10
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
amitlee9823
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
Abortion pills in Kuwait Cytotec pills in Kuwait
 

Último (20)

How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptx
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investors
 
Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperity
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentation
 
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 

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.