CCP(Concurrency Control Protocols)

Concurrency Control in Database Management System is a  procedure of managing simultaneous operations without conflicting with each other. It is required for controlling the concurrent execution of the operations on a database. Concurrency control is the working concept that is required for controlling and managing concurrent execution of database operations and thus avoiding the inconsistencies in the database. Therefore, for maintaining concurrency we have concurrency control protocols.

Concurrency Control Protocols

In the present scenario of a multiprogramming environment where multiple transactions can be executed simultaneously, it is highly important to control the concurrency of transactions. Therefore, for this, we have concurrency control protocols to ensure atomicity, isolation, and serializability of concurrent transactions. 

Concurrency Control Protocols can be broadly classified into two main categories:-

  • Lock-based concurrency control Protocol
  • TimeStamp-based concurrency control Protocol

Lock based concurrency control Protocol

Database systems equipped with lock-based protocols use a mechanism by which any transaction cannot read or write data until it acquires an appropriate lock on it. 

Locks are of two types:

  1. Shared lock: In this, the data can only be read by transaction therefore it is also known as a read-only lock.
  2. Exclusive lock: In this lock, the data item can be both reads as well as written by the transaction.

There are four types of Lock Protocols :

  1. Simplistic Lock Protocol
  2. Pre-claiming Lock Protocol
  3. Two-phase locking (2PL)
  4. Strict Two-phase Locking (Strict 2-PL)

TimeStamp-based concurrency control Protocol

The TimeStamp-based concurrency Control Protocol is used to order the transactions based on their timestamps. The order of transaction is nothing but the ascending order of the transaction creation. It is the most commonly used concurrency protocol. It uses either system time or logical counter as a lifestamp. It starts working as soon as the transaction is created. The priority of older transactions is higher, that’s why it executes first.