Two phase locking

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 the resulting "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

A Lock is a database system object, associated with a database object (typically a data item). It is associated (applied) by a transaction with (to) the database object before accessing it. Lock existence prevents undesired (typically synchronization rule violating) operations of other transactions from acting upon that database object by blocking them. A database operation upon a database object checks for lock existence for that object, and halts when noticing a lock type that is intended to block it (according to a predefined agreement/locking-scheme).

According to the two phase locking protocol, a transaction handles its locks 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.

trict 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". On the other hand, "read (shared)" locks are released regularly during phase 2.

Typically end of Phase 1 is safely determined when a transaction has entered its "ready" state in all its processes (processing has ended, and it is ready to be committed; no additional locking is possible). If several processes (two or more) are involved, then a synchronization point (similar to "atomic commitment") among them is needed to determine end of Phase 1 for all of them. This is usually too costly, and end of Phase 1 is usually postponed to be merged with transaction end (atomic commitment protocol for a multiprocess transaction), which turns S2PL to SS2PL (see below).

S2PL is a special case of 2PL, i.e., the S2PL class is a proper subclass of 2PL.

trong 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 a 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. Many variants of SS2PL exist that utilize various lock types with various semantics in different situations, including cases of lock-type change during a transaction. Notable are variants that use multi-granularity locking.

ee also

*Serializability
*Lock (computer science)


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Two-phase locking — This article is about concurrency control. For commit consensus within a distributed transaction, see Two phase commit protocol. In databases and transaction processing two phase locking, (2PL) is a concurrency control method that guarantees… …   Wikipedia

  • Strict two-phase locking — In computer science, strict two phase locking (Strict 2PL) is a locking method used in concurrent systems.The two rules of Strict 2PL are:# If a transaction T wants to read/write an object, it must request a shared/exclusive lock on the object. # …   Wikipedia

  • Rigorous two-phase locking — In computer science, rigorous two phase locking (Rigorous 2PL) is a locking method used in concurrent systems.The two rules of Rigorous 2PL are:# If a transaction T wants to read/write an object, it must request a shared/exclusive lock on the… …   Wikipedia

  • Conservative two-phase locking — In computer science, conservative two phase locking (C2PL) is a locking method used in DBMS and relational databases. Conservative 2PL prevents deadlocks. The difference between 2PL and C2PL is that C2PL s transactions obtain all the locks they… …   Wikipedia

  • Phase-locked loop — PLL redirects here. For other uses, see PLL (disambiguation). A phase locked loop or phase lock loop (PLL) is a control system that generates an output signal whose phase is related to the phase of an input reference signal. It is an electronic… …   Wikipedia

  • Phase-locked Loop — Eine Phasenregelschleife, auch als Phase locked loop (PLL) bezeichnet, ist eine elektronische Schaltungsanordnung, die die Phasenlage und damit zusammenhängend die Frequenz eines veränderbaren Oszillators über einen geschlossenen Regelkreis so… …   Deutsch Wikipedia

  • Phase-locked loop — Eine Phasenregelschleife, auch als englisch Phase locked loop (PLL) bezeichnet, ist eine elektronische Schaltungsanordnung, die die Phasenlage und damit zusammenhängend die Frequenz eines veränderbaren Oszillators über einen geschlossenen… …   Deutsch Wikipedia

  • Multiple granularity locking — In computer science, multiple granularity locking (MGL), sometimes called the John Rayner locking method, is a locking method used in database management systems (DBMS) and relational databases. In MGL, locks are set on objects that contain other …   Wikipedia

  • Mode-locking — is a technique in optics by which a laser can be made to produce pulses of light of extremely short duration, on the order of picoseconds (10−12 s) or femtoseconds (10−15 s). The basis of the technique is to induce a fixed phase… …   Wikipedia

  • Tidal locking — A separate article treats the phenomenon of tidal resonance in oceanography. : See the article tidal acceleration for a more quantitative description of the Earth Moon system. Tidal locking occurs when the gravitational gradient makes one side of …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”