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

📅  最后修改于: 2021-09-08 16:23:38             🧑  作者: Mango

先决条件 –两相锁定协议和两相锁定协议的类型

1. 保守的 2-PL :

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

2. 严格的 2-PL :

  • 2-PL 最流行的变体是 Strict 2-PL。
  • 它是 Rigorous 2-PL 的轻型版本。
  • 这要求除了锁是 2-Phase 之外,事务持有的所有 Exclusive(X) 锁都被释放,直到事务提交之后。
  • 允许事务在提交之前释放共享锁。

Conservative 和 Strict 2-PL 的区别:

S.No. Conservative 2-PL Strict 2-PL
1. In Conservative 2-PL, A transaction has to acquire locks on all the data items it requires before the transaction begins it execution. In Strict 2-PL, A transaction can acquire locks on data items whenever it requires (only in growing phase) during its execution.
2. It does not have growing phase. It has growing phase.
3. It has shrinking phase. It has partial 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 less popular as compared to Strict 2-PL. It is the most popular variation of 2-PL.
8. It is not used in practise. It is the most popular variation of 2-PL.
9. In Conservative 2-PL, a transaction can read a value of uncommitted transaction. In Strict 2-PL, a transaction only reads value of committed transaction.