Cockroach Design 翻译 ( 八) 严格序列化(线性化)

本文探讨了CockroachDB中的线性化事务(即严序序列化)与序列化隔离级别的区别,强调了线性化事务如何通过保留因果性来提升一致性,并介绍了CockroachDB实现这一特性的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

10  Strict Serializability(Linearizability)严格序列化(线性化)

Roughlyspeaking, the gap between strict serializability (which we useinterchangeably with linearizability) and CockroachDB's defaultisolation level (serializable) is that with linearizable transactions,causality is preserved. That is, if one transaction (say, creating a postingfor a user) waits for its predecessor (creating the user in the first place) tocomplete, one would hope that the logical timestamp assigned to the former islarger than that of the latter. In practice, in distributed databases this maynot hold, the reason typically being that clocks across a distributed systemare not perfectly synchronized and the "later" transaction touches apart disjoint from that on which the first transaction ran, resulting in clockswith disjoint information to decide on the commit timestamps.

粗略来讲,严格序列化(我们使用另一个术语线性化来替代)和CockroachDB的默认隔离级别(序列化)的区别是:线性化事务保留了因果性。也就是说,如果一个事务(比方说,为用户创建一个帖子)等待它的前序事务(先创建该用户)完成,赋予前者的逻辑时间戳要大于后者。实际上,在分布式数据库系统中这可能无法保持,典型原因是跨越分布式系统的时钟无法精确同步,导致后面的事务与前面的事务运行节点时间有部分脱节,导致使用脱节信息的时钟来确定提交的时间戳。

In practice,in CockroachDB many transactional workloads are actually linearizable, thoughthe precise conditions are too involved to outline them here.

实践中,在CockroachDB中许多事务负载实际上是线性化的,尽管精确条件也被牵扯到这里的要点讨论中。

Causality istypically not required for many transactions, and so it is advantageous to payfor it only when it is needed. CockroachDB implements thisvia causality tokens: When committing a transaction, a causalitytoken can be retrieved and passed to the next transaction, ensuring that thesetwo transactions get assigned increasing logical timestamps.

Additionally,as better synchronized clocks become a standard commodity offered by cloudproviders, CockroachDB can provide global linearizability by doing much thesame that Google's Spanner does: wait out themaximum clock offset aftercommitting, but before returning to the client.

典型情况下,许多事务不需要因果性,因此只有需要时才会为此优势付出代价。CockroachDB通过因果令牌来实现:当提交一个事务时,检索因果令牌并传递给下一个事务,以确保这两个事务得到递增的逻辑时间戳。此外,通过云提供者提供了一个更好的同步时钟,它成了标准设施,CockroachDB会提供全局线性能力,很像 Google'sSpanner的做法:在返回客户端前,提交后静静地等待最大时钟补偿。

See the blogpost below for much more in-depth information.

更深入的信息请参见下面的微博:

https://www.cockroachlabs.com/blog/living-without-atomic-clocks/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值