📜  保守和严格2-PL之间的区别

📅  最后修改于: 2021-08-27 04:32:42             🧑  作者: Mango

先决条件–两相锁定协议,以及两相锁定的类别

1.保守2-PL:

  • 也称为静态2-PL。
  • 该协议要求事务在事务开始执行之前通过预先声明其读集和写集来锁定它访问的所有项目。
  • 如果无法锁定任何需要的预先声明的项目,则事务不会锁定任何项目,而是等待直到所有项目都可用于锁定。

2.严格的2-PL:

  • 这要求除了将锁锁定为两阶段以外,还应释放事务持有的所有互斥(X)和共享(S)锁,直到事务提交之后。
  • 严格性比严格2-PL更具限制性。
  • 严格的2-PL的实现很容易。

保守和严格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.