acid

Definition

Two-Phase Locking (ACID)

Two-phase locking is a protocol used to ensure conflict serialisability. It is a pessimistic protocol, meaning it assumes conflicts are likely and uses locks to prevent them before they happen.

The protocol is divided into two phases:

  1. Growing phase: A transaction can only acquire locks. When the first lock is released, it the transaction transitions into the second phase.
  2. Shrinking phase: Starts at the moment a transaction releases its first lock. From now on, the transaction can only release locks.

Two increase concurrency, locks can be upgraded from shared lock to exclusive lock during first phase and downgraded from exclusive lock to shared lock during second phase.

Deadlocks are not prevented by this.