dbms和sql_DBMS | 并发控制和各种并发控制方法

dbms和sql

并发控制 (Concurrency Control)

The concurrency control is the coordination of the simultaneous execution of a transaction in a multiuser database system. The concurrency control can ensure the serializability of the transaction in a multiuser database environment and that is the main objective of concurrency control. There is only One way in which the required data items can be accessed in a mutually exclusive manner. That is while one transaction is accessing a data item another transaction can modify that data item. The most common method used to implement this requirement is to allow a transaction to access a data item only if it is currently holding a lock on that item.

并发控制是在多用户数据库系统中同时执行事务的协调。 并发控制可以确保事务在多用户数据库环境中的可序列化性,这是并发控制的主要目标。 只有一种方法可以以互斥的方式访问所需的数据项。 也就是说,当一个事务正在访问数据项时,另一事务可以修改该数据项。 用于实现此要求的最常见方法是仅在事务当前持有该数据项的锁时,才允许该事务访问该数据项。

多种并发控制方法 (Various methods of concurrency control)

1)二进制锁定 (1) Binary Locking)

A data item can be locked in various modes:

数据项可以以多种模式锁定:

  • Shared mode (S): when any transaction Ti has 0 shared mode lock on any data item Q then Ti can only read but cannot write Q.

    共享模式(S) :当任何事务Ti对任何数据项Q拥有0个共享模式锁定时, Ti只能读取而不能写入Q。

  • Exclusive mode (X): Any transaction Ti can read and write Q only If a transaction Ti has obtained an exclusive mode lock (denoted by X) on any data item Q.

    独占模式(X) :只有事务Ti获得了对任何数据项Q的独占模式锁(由X表示),任何事务Ti才能读写Q。

  • The transaction makes the request to the concurrency control manager. It can proceed only when the concurring control manager grants the lock to the transaction.

    事务向并发控制管理器发出请求。 仅当并发控制管理器将锁定授予事务时,它才能继续进行。

2)基于锁定的协议 (2) Locked based protocol)

In locked based protocol basic idea is first to acquire a lock before accessing a data item directly after use should delete that data item. Because of this, we can avoid a clash. Here transaction uses types of locks. Shared lock and exclusive lock.

在基于锁定的协议中,基本思想是首先获取一个锁,然后再直接使用该数据项,然后再删除该数据项。 因此,我们可以避免冲突。 在这里,事务使用锁的类型。 共享锁和排他锁。

3)共享锁 (3) Shared lock)

If the transaction has acquired a shared lock on a data item Q than its own perform only read operation but if a transaction has acquired exclusive lock then it can perform read as well as write operation.

如果事务已获取了对数据项Q的共享锁,而不是事务本身仅执行读操作,但是如果事务已获取了排他锁,则它可以执行读和写操作。

4)两相锁定 (4) Two phase locking)

In two-phase locking every transaction work in 2 phase in the entire span. Growing phase and shrinking phase. In the growing phase, only a transaction may acquire locks but cannot release only lock while in shrinking phase a transaction can only release lock but cannot any acquire any lock.

在两阶段锁定中,每个事务在整个范围内分两阶段进行。 生长阶段和收缩阶段。 在增长阶段,只有事务可以获取锁,而不能仅释放锁,而在收缩阶段,事务只能释放锁,而不能获取任何锁。

Growing and shrinking phase terminology is applicable to the transaction not suitable.

增长和收缩阶段术语适用于不适合的交易。

5)严格的2相锁定 (5) Rigorous 2 phase locking)

In rigorous 2 phase locking, we remove shrinking phases from the system i.e. a transaction can acquire locks but cannot release any lock because of which dirty read is not possible. This protocol ensures conflict and view serializability recoverability and cascadeless but may suffer from deadlock.

在严格的两阶段锁定中,我们从系统中删除了缩小的阶段,即,事务可以获取锁定,但不能释放任何锁定,因为这样不可能进行脏读。 该协议可确保冲突并查看可序列化的可恢复性,并且无级联,但可能会出现死锁。

6)严格2相锁相 (6) Strict 2 phase locking)

In strict 2 phase locking is an improvement over rigorous 2 phase locking ensure rigorous two-phase locking where unlocking of a shared lock is allowed in the shrinking phase.

在严格的2相锁定中,是对严格2相锁定的一种改进,可确保严格2相锁定,其中在收缩阶段允许对共享锁进行解锁。

7)保守2相锁相 (7) Conservative 2 phase locking)

In conservation 2 phase locking we remove growing phase from the system and every transaction is first required to acquire all the lock first before performing any read or write. It ensures conflict serializability view serializability and deadlock independence but suffers from recoverability and cascades.

在保护2阶段锁定中,我们从系统中删除了增长阶段,在执行任何读取或写入操作之前,首先需要每个事务先获取所有锁定。 它确保了冲突的可序列化性,视图可序列化性和死锁独立性,但是会遭受可恢复性和级联的困扰。

8)时间戳记协议 (8) Time stamping protocol)

In this method, we decide to order before transaction enters into the system here every transaction is given time stamp Ts(Ti) which is actually the value of the system clock when the transaction enters into the system. This time stamp will remain constant until the transaction is in the system.

在这种方法中,我们决定在事务进入系统之前进行排序,此处为每个事务都赋予时间戳Ts(Ti),该时间戳实际上是事务进入系统时系统时钟的值。 该时间戳将保持不变,直到事务在系统中。

Write every data item Q use associate two time stamp read time stamp of Q and write time stamp of Q.

写入每个数据项Q使用关联Q的两个时间戳读取时间戳和Q的写入时间戳。

Note: If a read operation is allowed than reading timestamp must be updated and if a write operation is allowed than write timestamp must be updated. If an operation is not allowed than transaction must enter into a system with a new timestamp.

注意:如果允许读取操作,则必须更新读取时间戳;如果允许写入操作,则必须更新写入时间戳。 如果不允许某项操作,则事务必须以新的时间戳进入系统。

翻译自: https://www.includehelp.com/dbms/concurrency-control-and-various-methods-of-concurrency-control.aspx

dbms和sql

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值