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
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
This comment has been removed by a blog administrator.
ReplyDeleteThis 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.
ReplyDeletecommercial kitchen hood cleaning services near me
emergency call
wedding transport Perth
wedding car rental with driver