Two phase locking
In Databases and Transaction processing, Two phase locking, (2PL) is a concurrency control locking protocol, mechanism, that guarantees Serializability. It is also the name of a class (set) of transaction schedules. Using locks that block processes, 2PL is subject to deadlocks that result from the mutual blocking of two transactions or more.
Two phase locking
According to the Two phase locking protocol, locks are handled by a transaction in two distinct, consecutive phases during the transaction’s execution:
Phase 1: Locks are acquired and no locks are released.
Phase 2: Locks are released and no locks are acquired.
The serializability property is guaranteed for a schedule with transactions that obey the protocol. The 2PL schedule class is defined as the class of all the schedules comprising transactions with data access orders that could be generated by the 2PL protocol.
Strict two phase locking
The Strict two phase locking (S2PL) class of schedules is the intersection of the 2PL class with the class of schedules possessing the Strictness property.
To comply with the S2PL protocol a transaction needs to comply with 2PL, and release its write (exclusive) locks only after it has ended, i.e., being either committed or aborted.
S2PL is a special case of 2PL, i.e., the S2PL class is a proper subclass of 2PL.
Strong strict two phase locking
To comply with the Strong strict two phase locking (SS2PL) protocol a transaction needs to comply with 2PL, and release both its write (exclusive) and read (shared) locks only after it has ended, i.e., being either committed or aborted.
A transaction obeying SS2PL can be viewed as having Phase 1 that lasts its entire execution duration, and no Phase 2 (or degenerate Phase 2). Thus, only one phase is actually left, and “two-phase” in the name seems to be still utilized due to the historical development of the concept from 2PL. The SS2PL property of a schedule is also called Rigorousness, and an SS2PL schedule is also called a Rigorous schedule.
SS2PL is a special case of S2PL, i.e., the SS2PL class of schedules is a proper subclass of S2PL (every SS2PL schedule is also an S2PL schedule, but S2PL schedules exist that are not SS2PL).
SS2PL is the concurrency control protocol of choice for most database systems since it provides besides serializability also Strictness, which is instrumental for efficient database recovery, and also Commitment ordering (CO) for participating in environments where a CO based Global serializability solution is employed.
See also
- Serializability
- Lock (computer science)