1. Lock Types


1.1 Execution

  1. Transactions request locks (or upgrades).
  2. Lock manager grants or blocks requests.
  3. Transactions release locks.
  4. Lock manager updates its internal lock-table.
    1. What transactions hold what locks
    2. What transactions are waiting to acquire any locks.

2. Two-Phase Locking


Untitled

Two-phase locking (2PL) is a concurrency control protocol that determines whether a txn can access an object in the database on the fly.

Untitled

The protocol does not need to know all the queries that a txn will execute ahead of time.

It’s sufficient to guarantee conflict serializability, since it generates schedules whose precedence graph is acyclic

Phase #1: Growing

Each txn requests the locks that it needs from the DBMS’s lock manager.

The lock manager grants/denies lock requests.

Phase #2: Shrinking