Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
86
|
第
5
章
5.3
并发控制
当在 1.1 节中讨论数据库的架构时,我们提到事务管理器和锁管理器协同工作以处理并
发控制。并发控制是一组用于处理并发事务间交互的技术。这些技术可以大致分为以下
几类:
乐观并发控制
乐观并发控制(OCC)允许多个事务执行并发的读取和写入操作,最后确定其执行
结果能否被串行化(serializable
译注 1
)。换句话说,事务不会彼此阻塞,而是保留其
操作历史,并在提交前检查这些历史操作是否存在冲突的可能。如果会产生冲突,
则中止其中某一个冲突的事务。
多版本并发控制
多版本并发控制(MVCC)允许一条记录同时存在多个时间戳的版本,通过这种方
式保证事务读到的是数据库过去某个时刻的一致视图。MVCC 可以使用验证技术来
实现,即只允许多个更新或事务提交中的某一个获胜,也可以使用无锁技术(例如
时间戳排序)或基于锁的技术(例如两阶段锁)。
悲观并发控制
悲观(也称为保守)并发控制(PCC)既有基于锁的实现,也有不加锁的实现,它们
的主要区别在于如何管理和授权对共享资源的访问。基于锁的实现要求事务维护数
据库记录上的锁,以防止其他事务修改被加锁的记录或访问当前事务正在修改的记
录,直到锁被释放为止。不加锁的实现根据未完成事务的调度,维护读取与写入的
操作列表以限制事务的执行。悲观的调度可能导致死锁:多个事务需要互相等待对
方释放锁才能继续执行。
在本章中,我们重点介绍节点本地的并发控制技术。第 13 章将会介绍分布式事务以及
其他方法,例如确定性并发控制(参见 13.4 节 )。
在进一步讨论并发控制之前,我们需要明确要解决的问题集,并讨论事务操作会以怎样 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley

Publisher Resources

ISBN: 9787111655169