3. Concurrency Control
▪ Pessimistic concurrency control
Check before a database operation is executed by locking data
ite...
3. Concurrency Control
▪ Locking techniques for concurrency control
☞ Locking data items is one of the main techniques use...
3. Concurrency Control
▪ Types of Locks
1) Binary locks
☞ Only two states:
locked (lock_item(x) operation)
unlocked (unloc...
3. Concurrency Control
▪ Types of Locks
1) Binary locks
☞ Two operations, lock_ and unlock_item are used with binary locki...
3. Concurrency Control
▪ Types of Lock
2) Certify lock
☞ Used to improving performance of locking protocols.
3) Conversion...
3. Concurrency Control
▪ Locks don’t guarantee serialisability: lost update

♪. Schedule 1: t1 followed by t2
♪. Schedule ...
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) prec...
3. Concurrency Control
▪ Ensuring serialisability: two-phase locking
• All locking operations (read_lock, write_lock) prec...
3. Concurrency Control
▪ Two-phase locking(TPL)
• Basic 2pl
When a transaction releases a lock, it may not request another...
3. Concurrency Control
▪ Locking problems: deadlock
Each of two or more transactions is waiting for the other to release a...
3. Concurrency Control
▪ Starvation
If concurrency control manager is badly designed.
Ex)
A transaction may be waiting for...
Upcoming SlideShare
Loading in...5
×

2 con control

127

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
127
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

2 con control

  1. 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. 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. 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. 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. 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. 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. 7. 3. Concurrency Control ▪ Non-serialisable schedule s that uses locks Let x=20, y=30. Result of s x=50, y=50.
  8. 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. 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. 10. 3. Concurrency Control ▪ Two-phase locking(TPL) • Basic 2pl When a transaction releases a lock, it may not request another lock.
  11. 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. 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.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×