Concurrency Control

From: database replication - Optimistic vs Multi Version Concurrency Control - Differences? - Stack Overflow

There are 2 main concurrency control approaches:

  • Pessimistic Concurrency Control: this approach assumes that conflicting operations happen more frequently (that's why it's called pessimistic). Since the conflicts are common, this approach makes use of locks to prevent conflicting operations from executing, assuming that there is no significant overhead from their usage.
  • Optimistic Concurrency Control: this approach assumes that conflicting operations are rare and they do not happen so frequently. Under this assumptions, the locks would impose significant & not needed overhead to the performance. For this reason, this approach generally avoids locking and attempts to execute the operations, checking (at the commit of each transaction), whether there has been a conflict with another transaction during its operations. If there was any conflict, this approach proceeds with aborting the transactions that had conflicting operations.

One widely known algorithm of pessimistic concurrency control is the 2-phase locking.

Two widely known algorithms of optimistic concurrency control are:

Optimistic concurrency control (OCC), also known as optimistic locking, is a non-locking concurrency control method. (From: Optimistic concurrency control - Wikipedia)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
并发控制和数据库系统恢复是数据库管理系统中两个重要的方面。并发控制主要涉及到在多个用户同时访问数据库时如何保证数据的一致性和完整性。 在数据库系统中,多个用户可以同时执行不同的事务,这可能导致读取和写入冲突。并发控制的目标是确保事务并发执行时数据库的一致性不会受到破坏。为了达到这个目标,数据库系统采取了多种技术和机制,比如锁机制、并发调度算法和事务隔离级别。 锁机制是实现并发控制的一种常用方法。当一个事务需要对数据库中的某个数据进行读取或写入时,它必须先获取相应的锁。如果其他事务已经获得了相同的锁,那么当前事务就需要等待,直到其他事务释放锁。通过锁机制,可以确保同一时间只有一个事务能够修改某个数据,从而保证数据的一致性。 另一个重要的方面是数据库系统的恢复机制。当数据库遭受到意外故障导致数据损失或不一致时,恢复机制会负责将数据库恢复到一致的状态。数据库系统通常会使用事务日志来记录每个事务的操作,包括读取和写入操作。如果发生故障,可以使用事务日志来重演事务,并恢复到故障之前的状态。其中一种常见的恢复技术是Aries算法,它使用了WAL(Write-Ahead Logging)和差量恢复的机制,可以有效地恢复数据库系统。 综上所述,并发控制和恢复是数据库系统中非常重要的两个方面。并发控制保证了多个事务同时访问数据库时的数据一致性,恢复机制则确保在故障发生时能够将数据库恢复到一致的状态。这些技术和机制的应用使得数据库系统能够提供高效可靠的数据访问和处理能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值