Show that a static two-phase locking schedule satisfies the condition for…

2011

Show that a static two-phase locking schedule satisfies the condition for dynamic two-phase locking. Is the converse true?

Show answer & explanation

Concept. A locking schedule obeys the two-phase locking (2PL) rule when every transaction in it has a single lock point: the transaction never acquires a lock after it has released one, so it passes through one growing phase and then one shrinking phase. Dynamic (basic) 2PL asks only for that ordering — a transaction may request a lock at any moment while it runs, provided it has released nothing yet. Static (conservative, or pre-claiming) 2PL is stricter about when locks are taken: a transaction must obtain its entire lock set in one atomic step before it executes its first operation, and it proceeds only once every one of those locks has been granted.

The static rule constrains only when locks are acquired, never how long they are held: a static transaction may release a lock while it is still running, because it will never ask for another one. Holding locks until the end of the transaction is a separate, additional restriction — strict 2PL keeps a transaction’s exclusive (write) locks until it commits or aborts, and rigorous 2PL keeps all of its locks, shared ones included, until that same point.

Application — every static schedule is a two-phase schedule. Let S be any schedule produced under static two-phase locking and let T be an arbitrary transaction of S.

  1. By the static rule, every lock request of T lies inside the initial pre-claim block, issued before T performs its first read or write.

  2. No release by T can fall inside that block: an unlock is itself an operation of T, and the pre-claim block completes before T executes its first operation.

  3. Therefore every lock request L of T appears earlier in the schedule than every release U of T; in particular T never acquires a lock after it has released one.

  4. That ordering is exactly the two-phase condition. The lock point of T is the end of the pre-claim block; the block itself is the growing phase, and everything from the first release onward is the shrinking phase.

  5. T was arbitrary, so every transaction of S is two-phase and S is a legal dynamic two-phase locking schedule. Static 2PL is therefore contained in dynamic 2PL, and a static schedule inherits conflict serializability from it.

Converse — no, and the inclusion is proper. A dynamic two-phase locking schedule need not obey the static rule. Take the single transaction below.

T1: lock-X(A); read(A); write(A); lock-X(B); read(B); write(B); unlock(A); unlock(B)
  • Every lock request precedes every release, so T1 is two-phase and the schedule is legal under dynamic 2PL.

  • The lock on B is requested only after T1 has already read and written A, so T1 never pre-claimed its full lock set and the schedule is illegal under static 2PL.

Cross-check — what the stricter rule buys and costs.

Aspect

Static (conservative) 2PL

Dynamic (basic) 2PL

Lock acquisition

Whole lock set pre-claimed atomically before the first operation

Requested on demand while the transaction runs

Two-phase condition

Satisfied; the pre-claim block is the growing phase

Satisfied by definition of the protocol

Deadlock

Impossible, because the pre-claim is all-or-nothing

Possible; needs detection or prevention

Concurrency

Lower, since locks are held from the start of the transaction

Higher, since a lock is taken only when it is needed

Class of schedules

A proper subset of the dynamic 2PL schedules

A superset that also contains non-static schedules

Result. Every static two-phase locking schedule satisfies the dynamic two-phase locking condition, so static 2PL is contained in dynamic 2PL. The converse does not hold: the transaction above is a dynamic 2PL schedule that is not a static one, so the containment is strict.

Explore the full course: Database Management System

Loading lesson…