(CMU15-721) An Empirical Evaluation of In-Memory MVCC 论文阅读笔记

这篇博客是关于CMU15-721课程中对多版本并发控制(MVCC)的深入探讨,涵盖了MVCC的基本概念、快照隔离的局限性、以及多种MVCC实现策略如Timestamp Ordering、MVOCC和MV-2PL。博主指出,虽然MVCC提高了并发性能,但需要注意写偏斜问题。此外,文章讨论了不同存储策略如Append-Only和Time-Travel Storage,并分析了它们的优缺点。最后,博主提到了数据库如Postgres和MySQL在索引管理上的不同策略。
摘要由CSDN通过智能技术生成

https://github.com/AlexanderChiuluvB/db-learning-material
欢迎star! 我做的数据库学习资料整理

不好意思大部分是英文,点进来的应该都是master PHD了吧?这部分是15721第三课的课堂笔记,发现就是相当于把这篇论文讲了一遍。如果只读论文的话还是挺难的。。

Multi-version concurrency control

Definition

DBMS maintains multiple physical versions of a single logical object in the db.

  • A txn writes to an object, then the DBMS creates a new version of that object.
  • A txn reads an object, it reads the newest version that existed when the txn started.

Compared to 2PL, MVCC has the following properties:

Writers do not block readers.

Readers do not block writers.

Read-only txns can read a consistent snapshot without acquiring locks or txn ids.

As long as you do not do garbarge collection, you can even visit historic version of data, aka time -travel queries.

SNAPSHOT ISOLATION

When a transaction starts, it will see a consistent snapshot of the db since the txn started.

  • No torn writes from active txns.(Eg: txn A aims to update 10 tuples, when finishing updating 5 tuples, txn B starts, but it will not see the five updated tuples.)
  • If two txns update the same object, the first writer wins.(Based on the time they write)

中文:

  • 每一个数据都多个版本,读写能够并发进行
  • 每个事务相当于看到数据的一个快照
  • 写写不能并发,写写操作时需要加上行锁
  • 谁加行锁,谁可以顺利执行(采用了“first win”的原则),后面的写事务要么abort,要么等待前面的事务执行完成后再执行(以Oracle 和 SQL Server 、MySQL等为代表)。
Attention! Snapshot isolation is not serializable. ‘Write Skew Analomy’

Write Skew Definition:

from wiki:

In a write skew anomaly, two transactions (T1 and T2) concurrently read an overlapping data set (e.g. values V1 and V2), concurrently make disjoint updates (e.g. T1 updates V1, T2 updates V2), and finally concurrently commit, neither having seen the update performed by the other. Were the system serializable, such an anomaly would be impossible, as either T1 or T2 would have to occur “first”, and be visible to the other. In contrast, snapshot isolation permits write skew anomalies.

简单理解为两个并发进行的事务,由于更新的时候无法看到对方的更新,可能会导致产生违反一致性的更新结果。

数据库约束: A1+A2>0

A1,A2 实际值都为100
事务T1:
If (read (A1) +read (A2) >= 200)
{
Set A1 = A1 – 200
}
事务T2:
If (read (A1) +read (A2) >= 200)
{
Set A2 = A2 – 200
}

假设现在有2个事务:

Txn1:把所有白球变成黑球

Txn2:把所有黑球变成白球

两个事务开始的时候,分别看到的都是初始的两黑两白consistent snapshot的状态

而提交之后又是两黑两白,这样的情况我们不能说是可串行化的。

在这里插入图片描述

下面这种情况我们才可以说是可串行化。两个事务严格按照顺序进行,不能并发进行。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-DUjpNklR-1588601288585)(C:\Users\AlexanderChiu\AppData\Roaming\Typora\typora-user-images\1588518720107.png)]

下面是《An Empirical Evaluation of In-Memory MVCC》笔记,实际上是在CMU 15721第三课的课堂笔记

MVCC DESIGN DECISIONS

  • Concurrency Control Protocol

In in-memory DBMS, it will st

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值