InnoDB撤销日志和历史系统的基础

InnoDB implements multi-version concurrency control (MVCC), meaning that different users will see different versions of the data they are interacting with (sometimes called snapshots, which is a bit of a misleading term). This is done in order to allow users to see a consistent view of the system without expensive and performance-constraining locking which would limit concurrency. (This is where the “concurrency control” part of the term comes from; one alternative is locking everything the user may need.) Undo logging and InnoDB’s “history” system are the mechanisms that underly its implementation of MVCC, but the way this works is generally very poorly understood.

InnoDB 实现了多版本并发控制(MVCC),这意味着不同的用户将看到他们正在交互的数据的不同版本(有时称为快照,这是一个有点误导性的术语)。这样做是为了让用户在不限制并发性的情况下看到系统的一致视图。(这就是术语中“并发控制”部分的含义;另一种选择是锁定用户可能需要的所有内容。)撤销日志和 InnoDB 的“历史”系统是其实现 MVCC 的机制,但这种工作方式通常被理解得很差。

InnoDB keeps a copy of everything that is changed

InnoDB保留了所有更改的副本

The key thing to know in InnoDB’s implementation of MVCC is that when a record is modified, the current (“old”) version of the data being modified is first stashed away as an “undo record” in an “undo log”. It’s called an undo log because it contains the information necessary to undo the change made by the user, reverting the record to its previous version.

在InnoDB的MVCC实现中,需要了解的关键事项是,当记录被修改时,首先将正在修改的当前(“旧的”)版本的数据存储为“撤销记录”在“撤销日志”中。它被称为撤销日志,因为它包含了撤消用户所做更改的信息,将记录恢复到其先前的版本。

Every record contains a reference to its most recent undo record, called a rollback pointer or ROLL_PTR, and every undo record contains a reference to its previous undo record (except for an initial record insert, which can be undone by simply deleting the record), forming a chain of all previous versions of a record. In this way, any previous version of a record can be easily constructed, as long as the the undo records (the “history”) still exist in the undo logs.

每个记录都包含对其最新的撤销记录的引用,称为回滚指针或ROLL_PTR,每个撤销记录都包含对其上一个撤销记录的引用(除了初始记录插入,可以通过简单地删除记录来撤销),形成记录的所有先前版本的链。通过这种方式,只要撤销日志中的撤销记录(“历史”)仍然存在,就可以轻松构建记录的任何先前版本。

Transactions always op...

开通本站会员,查看完整译文。

Home - Wiki
Copyright © 2011-2024 iteam. Current version is 2.139.0. UTC+08:00, 2024-12-23 04:34
浙ICP备14020137号-1 $Map of visitor$