2,545 views
4 votes
4 votes
$\begin{bmatrix} T1 &T2 \\ R(A) & \\ W(A)& \\ & R(A)\\ & W(A)\\ &R(B) \\ &W(B) \\ & Commit\\ Abort& \end{bmatrix}$

How is this schedule allowed in 2PL ? In 2PL , there must be a growing phase in , which is not present in T2 ..?

This example is given in the book by Raghu Ramkrishnan on page 529 and 552 (for reference)

2 Answers

2 votes
2 votes
T1 T2
Lock(A)  
R(A)  
W(A)  
Unlock(A) // Assuming that T1 does not need any more locks or those locks before unlocking it  
  Lock(A)
  Lock(B)
  R(A)
  W(A)
  R(B)
  W(B)
  Unlock (A)
  Unlock(B)
  Commit
Abort  

This is how it is possible to implement 2 Phase locking. I think you can see growing & shrinking phase. Issue is that 2 Phase locking in itself does not maintain good property like Deadlock or say recoverable schedule, just like Semaphore are used for synchronizing but we need to use them wisely, or they can cause deadlocks ! It is possible to follow 2 Phase locking , even when resulting schedule is not recoverable.

1 votes
1 votes
In strict2PL, a data item can be read only if the transaction which has previously written the value for the item has committed.

Here, T1 has written value of A and T1 has not committed. Before that T2 tries to read A. This is not possible in strict2PL