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

📅  最后修改于: 2021-06-29 11:38:52             🧑  作者: Mango

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

1.保守2-PL:

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

2.严格2-PL:

  • 2-PL最受欢迎的变体是Strict 2-PL。
  • 它是Rigorous 2-PL的较轻版本。
  • 这就要求除了锁是两阶段锁外,还必须释放事务持有的所有Exclusive(X)锁,直到事务提交之后。
  • 允许事务在提交前释放共享锁。

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