Skip to Content
数据库系统内幕
book

数据库系统内幕

by Alex Petrov
May 2020
Beginner to intermediate
319 pages
7h 3m
Chinese
China Machine Press
Content preview from 数据库系统内幕
分布式事务
|
233
定序器
分区 分区 分区
调度器
工作者
存储
定序器
调度器
工作者
存储
定序器
调度器
工作者
存储
图
13-7
:
Calvin
的架构
13.5 Spanner
分布式事务
Calvin 常常被拿来和另一个称为 Spanner[CORBETT12] 的分布式事务方法进行对比。
Spanner 的实现(或派生)包括几个开源数据库,最著名的是 CockroachDB 和 YugaByte
DB。Calvin 通过在定序器上达成共识来建立全局事务执行顺序,Spanner 则在每个分区
的共识组(换句话说,每个分片)上使用两阶段提交。Spanner 的架构相当复杂,本书中
我们仅介绍一些高层次上的细节。
为了实现一致性并建立事务的顺序关系,Spanner 使用
TrueTime
:一种高精度的物理时
钟 API,同时也暴露时钟误差的范围,允许本地操作中引入人为的减速以等待时钟误差
范围过去。
Spanner 提供三种主要的事务类型:
读写事务
、
只读事务
和
快照读
。读写事务需要加锁,
使用悲观的并发控制,并且存在领导者(leader)副本。只读事务是无锁的,可以在任
何副本上执行。只有在读取
最新
时间戳时才需要领导者,领导者负责从 Paxos 组中获取
最后提交的值。对特定时间戳的读取是一致的,因为数据有版本,而快照的内容一旦写
入就无法更改。每个数据记录都会被分配一个时间戳,记录了写入该值的事务的提交时
间。这也意味着每条记录可能存在多个时间戳的版本。
234
|
第
13
章
图 13-8 展示了 Spanner 的架构。每个 ...
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