Lock Based Protocols in Databse Transactions

Lock Based Protocols in Databse Transactions

Lock Based Protocols in Databse Transactions

  • Two Phase Locking Protocol
  • Conservative 2PL(Two Phase Locking)
  • Strict 2PL
  • Rigorous 2PL

Two Phase Locking Protocol

Two Phase Locking Protocol  has two phases.Growing Phase and Shrinking Phase. In Growing Phase transaction obtains locks but not releasing any locks.In Shrinking Phase transaction releases locks  and cannot obtain any new locks.Initially the transaction is in growing phase,that is the transaction acquires locks as needed. Once the transaction releases lock, it enters the shrinking phase and no more lock request may be issued. Upgrading of lock is not possible in shrinking phase, but it is possible in growing phase. The two phase locking protocol ensures serializability.
 
Conservative 2PL(Two Phase Locking)
In conservative 2PL there is no growing Phase, Only having shrinking Phase.It gets all the locks before the execution starts .
 

Strict 2PL
Not releasing the write lock (Exclusive Lock) until commit.

 

Rigorous 2PL
First commit then release the lock.