1. Conservative 2-PL :
- It is also called as Static 2-PL.
- This protocol requires the transaction to lock all the items it access before the Transaction begins execution by pre-declaring its read-set and write-set.
- If any of the pre-declared items needed cannot be locked, the transaction does not lock any of the items, instead, it waits until all the items are available for locking.
2. Rigorous 2-PL :
- This requires that in addition to the lock being 2-Phase all Exclusive(X) and Shared(S) Locks held by the transaction be released until after the Transaction Commits.
- Rigorous is more restrictive than Strict 2-PL.
- The implementation of Rigorous 2-PL is easy.
Difference between Conservative and Rigorous 2-PL :
|S.No.||Conservative 2-PL||Rigorous 2-PL|
|1.||A transaction has to acquire locks on all the data items it requires before the transaction begins it execution.||A transaction can acquire locks on data items whenever it requires (only in growing phase) during its execution.|
|2.||It does not have a growing phase.||It has a growing phase.|
|3.||It has a shrinking phase.||It does not have a shrinking phase.|
|4.||It ensures that the schedule generated would be Serializable and Deadlock-Free.||It ensures that the schedule generated would be Serializable, Recoverable and Cascadeless.|
|5.||It does not ensures Recoverable and Cascadeless schedule.||It does not ensures Deadlock-Free schedule.|
|6.||It does not ensure Strict Schedule.||It ensures that the schedule generated would be Strict.|
|7.||It is not used in practise as its difficult to implement.||It is easy to implement but a lighter version of it (i.e Strict 2-PL) is used in practise.|
|8.||In Conservative 2-PL, a transaction can read a value of uncommitted transaction.||In Rigorous 2-PL, a transaction only reads value of committed transaction.|
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.