Types of Two Phase Locking

There are two types of 2PL:
  • The Basic 2PL
  • Strict 2PL

The basic 2PL allows release of lock at any time after all the locks have been acquired.
For example, we can release the locks in schedule of Table: XYZ, after we have read the values of Y and Z in T3, even before the display of the sum. This will enhance the concurrency level.

The basic 2PL is shown graphically as follows:
Basic Two Phase Locking

However, this basic 2PL suffers from the problem that it can result into loss of atomic/isolation property of transaction as theoretically speaking once a lock is released on a data item it can be modified by another transaction before the first transaction commits or aborts.

To avoid such a situation we use strict 2PL. The basic disadvantage of strict 2PL is that it restricts concurrency as it locks the item beyond the time it is needed by a transaction.

Strict Two Phase Locking

The strict 2PL solves the problem of concurrency and atomicity, however it introduces another problem: "Deadlock".