CONCURRENCY in Database Management System

Harsh
NiXiS Institute
Published in
2 min readNov 23, 2019

INTRODUCTION of CONCURRENCY

  • In the concurrency control , many transactions executed simultaneously or in a single follow to read or write the transactions .
  • But conflicts or errors occurs due to multiple user’s system . To avoid this conflict concurrency control is used .It helps you to make sure that the database is performed concurrently without violating the data .

CONCURRENCY CONTROL PROTOCOLS

1. Lock - Based Protocol

2. Two - Phase Locking Protocol

1. Lock - Based Protocol :-

It is a data variable which is assignment with the data item . It gives permission for read or write the data from database .Transactions proceeds only once when lock request is granted .

There are two types of lock are here :-

1. Shared Lock :-

  • It is also known as read only lock .It allows the user to only read the data item ,not update on it.
  • This lock is shared between two transactions.
  • It is represented S - lock .

2. Exclusive Lock :-

  • It is also known as read as well as written lock . It allows user to both read as well as written on data item .
  • It is represented by lock - x .

2. Two - Phase Locking Protocol :-

  • Two - Phase Locking is also known as 2PL or P2L .
  • In this type of locking Protocol, transaction should acquire a lock after it releases one of its lock .
  • This Protocol divides execution phase of transaction into three parts .
  1. First phase :- When transaction begin to execute , it requires permission for the locks ot needs .
  2. Second phase :- In this phase transaction acquires all the locks which needed . When a transaction releases its first lock , the third phase starts .
  3. Third phase :- In this phase transaction releases its locks and cannot acquire any lock .

There are two of 2PL :-

1. Growing Phase :-

In this a new lock can be acquired for the data item , but can’t releases any lock .

2. Shrinking Phase :-

In this transaction can releases the existing lock , but can’t acquired new lock .

Thank You

--

--