BCA / B.Tech 6 min read

Serializability & Two-Phase Locking (2PL)

Serializability & Two-Phase Locking (2PL) in RDBMS:

What is Serializability:
Serializability is a property of transaction processing. It ensures that the outcome of executing multiple transactions concurrently is the same as if they were executed one after another (serially) in some order. It is the highest level of isolation between transactions and is a key mechanism for maintaining database consistency.

Two-Phase Locking (2PL):
Two-Phase Locking (2PL) is a concurrency control protocol used to guarantee serializability. It operates in two distinct phases for the lifetime of a transaction:
  1. Growing Phase: The transaction can obtain new locks on data items, but it cannot release any locks.
  2. Shrinking Phase: The transaction can release its existing locks, but it cannot obtain any new locks.
This protocol ensures that transactions are serializable, although it can lead to deadlocks if not managed carefully.