Growing Phase (Locking)

The transaction may obtain locks, but cannot release any locks.
Transaction can obtain a shared (read) lock or exclusive (write) lock on a data item before it is read or written to.

Shrinking Phase (Unlocking)

Once the transaction releases its first lock, the second phase starts, in which it can only release locks, but cannot obtain any new locks.
The transaction keeps all the locks until it completes all ‘write’ operations to maintain isolation and consistency.

The purpose of two-phase locking is to ensure that all the conflicting operations are executed in an order that is equivalent to some serial order to avoid concurrency related issues like dirty reads, unrepeatable reads, and phantom reads.

CASCADING ABORTS

image.png

Since T2 rely on T1

STRONG STRICT TWO-PHASE LOCKING

Prevent dirty read.
Release all locks only at end of txn.

Strict

A schedule is strict if a value written by a txn is not read or overwritten by other txns until that txn finishes.
Advantages:

  • Does not incur cascading aborts.
  • Aborted txns can be undone by just restoring original values of modified tuples.