...

/

Pessimistic Concurrency Control (PCC)

Pessimistic Concurrency Control (PCC)

In this lesson, we will explore the 2-phase locking, a pessimistic concurrency control protocol.

2-Phase locking (2PL)

2-phase locking (2PL) is a pessimistic concurrency control protocol that uses locks to prevent concurrent transactions from interfering. These locks indicate that a record is being used by a transaction, so that other transactions can determine whether it is safe to use it or not.

Types of locks

There are two basic types of locks used in this protocol:

  • Write (exclusive) locks: These locks are acquired when a record is going to be written (inserted/updated/deleted).
  • Read (shared) locks: These locks are acquired when a record is read.

Interaction between write (exclusive) locks and read (shared) locks

  • A read lock does not block a read from another transaction. This is why it is also called shared because multiple read locks can be acquired at the same time.
  • A read lock
...