Notes
Slide Show
Outline
1
 
2

Chapter 18

Concurrency Control Techniques
3
Chapter 18 Outline
  • Databases Concurrency Control
  • 1 Purpose of Concurrency Control
  • 2 Two-Phase locking
  • 5 Limitations of CCMs
  • 6 Index Locking
  • 7 Lock Compatibility Matrix
  • 8 Lock Granularity
4
Database Concurrency Control
  • 1   Purpose of Concurrency Control
      • To enforce Isolation (through mutual exclusion) among conflicting transactions.
      • To preserve database consistency through consistency preserving execution of transactions.
      • To resolve read-write and write-write conflicts.

    • Example:  In concurrent execution environment if T1 conflicts with T2 over a data item A, then the existing concurrency control decides if T1 or T2 should get the A and if the other transaction is rolled-back or waits.
5
Database Concurrency Control
  • Two-Phase Locking Techniques
    • Locking is an operation which secures (a) permission to Read or (b) permission to Write a data item for a transaction.  Example: Lock (X).  Data item X is locked in behalf of the requesting transaction.


    • Unlocking is an operation which removes these permissions from the data item.  Example: Unlock (X).  Data item X is made available to all other transactions.
    • Lock and Unlock are Atomic operations.
6
Database Concurrency Control
  • Two-Phase Locking Techniques: Essential components
  • Two locks modes (a) shared (read) and (b) exclusive (write).
    • Shared mode:  shared lock (X).  More than one transaction can apply share lock on X for reading its value but no write lock can be applied on X by any other transaction.
    • Exclusive mode: Write lock (X).  Only one write lock on X can exist at any time and no shared lock can be applied by any other transaction on X.
    • Conflict matrix
7
Database Concurrency Control
  • Two-Phase Locking Techniques: Essential components
    • Lock Manager: Managing locks on data items.
    • Lock table: Lock manager uses it to store the identify of transaction locking a data item,  the data item, lock mode and pointer to the next data item locked. One simple way to implement a lock table is through linked list.
8
Database Concurrency Control
  • Two-Phase Locking Techniques: Essential components
    • Database requires that all transactions should be well-formed.  A transaction is well-formed if:


9
Database Concurrency Control




10
Database Concurrency Control




11
Database Concurrency Control




12
Database Concurrency Control




13
Database Concurrency Control




14
Database Concurrency Control




15
Database Concurrency Control




16
Database Concurrency Control




17
Database Concurrency Control




18
Database Concurrency Control




19
Database Concurrency Control




20
Database Concurrency Control




21
Database Concurrency Control




22
Database Concurrency Control




23
Database Concurrency Control




24
Database Concurrency Control




25
Database Concurrency Control




26
Database Concurrency Control




27
Database Concurrency Control




28
Database Concurrency Control




29
Database Concurrency Control



30
Database Concurrency Control



31
Database Concurrency Control



32
Database Concurrency Control



33
Database Concurrency Control



34
Database Concurrency Control



35
Database Concurrency Control



36
Database Concurrency Control



37
Database Concurrency Control



38
Database Concurrency Control



39
Database Concurrency Control



40
Database Concurrency Control



41
Database Concurrency Control



42
Database Concurrency Control



43
Database Concurrency Control



44
Database Concurrency Control



45
Database Concurrency Control



46
Database Concurrency Control