Monday, 17 February 2014

Two phase locking protocol in concurrency control | Transaction management


TWO PHASE LOCKING PROTOCOL(PESSIMISTIC APPROACH)

A transaction follows the two phase locking protocol, if all the locking operations precede the first unlock operation in the transaction. There are two phases in the Schedule. These are:

1.) GROWING PHASE- During which all the locks are requested.
2.) SHRINKING PHASE- During which all the locks are released.

Initially a transaction is in the growing phase. The transaction acquires locks as needed. Once the transaction releases a lock, it enters the shrinking phase and it can issue no more lock requests.

For Example:

             Lock X(A) 

             Read(A)   
             A:= A-200    GROWING PHASE
             Write(A)
             Lock X(B)
             ---------
             Unlock(A)
             Read(B)
             B:=B+200     SHRINKING PHASE
             Write(B)
             Unlock(B)

PROBLEMS WITH TWO PHASE LOCKING PROTOCOL:-

1.) Deadlock
2.) Cascading Roll-Back

2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This is a clear and concise explanation of the Two-Phase Locking protocol and its importance in maintaining concurrency control within database transactions. The distinction between the growing and shrinking phases makes the locking process easy to understand, while highlighting issues such as deadlocks and cascading rollbacks provides a balanced view of its practical limitations. Overall, the article presents the core concept effectively and serves as a useful introduction to transaction management and serializability.
    commercial kitchen hood cleaning services near me
    emergency call
    wedding transport Perth
    wedding car rental with driver

    ReplyDelete