~ Office Supplies ~~ Buy Posters ~~ A-Z Products ~~ Website Advertising


Strict two-phase locking - Wikipedia

<<Up     Contents

Strict two-phase locking

In computer science, strict two-phase locking (Strict 2PL) is a locking method used in database management systems.

The two rules of Strict 2PL are:

  1. If a transaction T wants to read/write an object, it must request a shared/exclusive lock on the object.
  2. All locks held by transaction T are released when T commits (and not before).

Here is an example of Strict 2PL in action with interleaved actions.

<math>D = \begin{bmatrix}
T1 & T2 \\ S(A) & \\ R(A) & \\
  & S(A)  \\
 & R(A) \\
 & X(B)\\
 & R(B) \\
 & W(B)\\

 & Com. \\
X(C) & \\ R(C) & \\ W(C) & \\ Com. &\end{bmatrix}</math>

or in text form:

T1: S(A), R(A); T2: S(A), R(A), X(B), R(B), W(B), Commit; T1: X(C), R(C), W(C), Commit

where

Strict 2PL prevents transactions reading uncommitted data, overwriting uncommitted data, and unrepeatable reads. It does not guarantee that deadlocks cannot occur, which can be important in real time systems[?], and may additionally be difficult to enforce in distributed data bases[?], or fault tolerant[?] systems with multiple redundancy.

A deadlocked schedule supposedly allowed in Strict 2PL:

<math>G = \begin{bmatrix}
T1 & T2\\ X(A) & \\
  & X(B) &  \\
X(B) & \\
 & X(A) \end{bmatrix}</math>

Text: T1: X(A) T2:X(B) T1:X(B) T2: X(A)

T1 is waiting for T2's lock on B to be released, while T2 is waiting for T1's lock on A to be released. These transactions cannot proceed and is deadlocked.

If an user wishes to guarantee that no deadlocks occur, 2PL would be one option. Assigning Timestamps would be another.

wikipedia.org dumped 2003-03-17 with terodump




 
 
158 carats gray AGATE gem Polished slab rectangle block Cabbing cab cabochon rough gemstone 31 grams
 158 carats gray AGATE Polished slab rectangle block Cabbing cab cabochon 31 grams 
 
30 gram picture MOONSTONE feldspar orthoclase gem Cab cabochon raw rough jewelry gemstone 154 carat
 30 gram picture MOONSTONE feldspar orthoclase Cab cabochon raw jewelry 154 carat 
 
15 carats yellow Oregon SUNSTONE gem stones Semi Facet cabbing rough gemstones lot Faceting jewels
 15 carats yellow Oregon SUNSTONE Semi cabbing lot ing jewels 
 
Red green AMMOLITE gem stone Freeform cabochon cabbing jewelry rough Ammonite opal 10 carats 2 grams
 Red green AMMOLITE Freeform cabochon cabbing jewelry Ammonite opal 10 carats 2 grams 
 
22 carat green new jade Serpentine rough gemstone tumble polished nugget drilled necklace bead Nice
 22 carat green new jade Serpentine tumble polished nugget drilled necklace bead Nice