当前位置:网站首页>Underlying mechanism mvcc
Underlying mechanism mvcc
2022-07-02 06:47:00 【fnfd】
Isolation level implementation principle (MVCC)
MVCC( Multi version concurrency control Multi-Version Concurrent Control) yes MySql One way to improve performance , coordination Undo log And version chain , Let different things read - Write , Write - Loss operations can be executed concurrently , So as to improve the system performance .
MVCC Make the database read will not lock the data , ordinary SELECT The request will not be locked , It improves the concurrent processing ability of data . With the help of MVCC, The database can be implemented ( Read submitted )READ COMMITTED,( Repeatable )REPETABLE READ Wait for the isolation level .
InnoDB Of MVCC This is achieved by saving two hidden columns after each row of records , A thing that preserves rows Id(DB_TRX_ID), A rollback pointer that holds the row (DB_ROLL_PT).
db_trx_id: Every time a cluster index record is changed , Will put the corresponding transaction id Assign a value to trx_id Hide columns .
db_roll_pt: Every time a cluster index record is changed , Will write the old version to undo log In the log , Then the hidden column is equivalent to a pointer , It can be used to find the information before the modification of the record .
ReadView
Read View When the transaction is started , A collection of all current transactions , This data structure stores the current Read View The largest of ID And the smallest ID
For the use of READ UNCOMMITTED( Read uncommitted ) For isolation level transactions , Just read the latest version directly , For the use of SERIALIZABLE( Serialization ) For isolation level transactions , Using lock to access records .
For the use of READ COMMITTED( Read submitted ) and REPETABLE READ( Repeatable ), You need to use version chain , Core issues : You need to determine which version in a version chain is visible to the current transaction .
ReadView: It mainly includes those active read-write transactions in the current system , Put their affairs id Put it in a table .
m_ids: It means generating ReadView Active read / write transactions in the current system id list .
min_trx_id: Generate ReadView It is the smallest thing in the active read-write transactions in the current system id, That is to say m_ids Minimum of .
max_trx_id: Generate ReadView Should be assigned to the next transaction in the system id, Not an active list m_ids Maximum of .
creator_trx_id: Generate this ReadView Affairs of things id;
Current version transactions id, At present ReadView Of create_trx_id(cid).
if id=cid, Indicates that the current transaction is modified by itself , Can be accessed , Directly return to this version .
if id<cid, Indicates the modification of the transaction committed before the current transaction , Can be accessed .
if id>ReadView Of mix_trx_id, Indicates that the version generated by transaction modification is enabled after the transaction , Can't be accessed , Continue to access backward along the version chain .
If this version of the transaction id At present ReadView Of min_trx_id and max_trx_id We need to judge , Modified this version of the transaction id Is it active , That is to say m_ids In the list , It means that the transaction of this version has not been committed at this time , Then this version cannot be accessed . If not active , The description is modified by the submitted transaction , Can be accessed .
If the version chain of this record is accessed , Are inaccessible , There is no such record in the query result .
READ COMMITTED-- Generate a... Before each read ReadView. The current reading
REPEATBLE READ-- Generate a... When reading data for the first time ReadView Read the snapshot .
边栏推荐
- Win10:添加或者删除开机启动项,在开机启动项中添加在用户自定义的启动文件
- ModuleNotFoundError: No module named ‘jieba. analyse‘; ‘ jieba‘ is not a package
- After reading useful blogs
- Fe - wechat applet - Bluetooth ble development research and use
- Eggjs -typeorm 之 TreeEntity 实战
- CTF three count
- Latex error: the font size command \normalsize is not defined problem solved
- Sentinel rules persist to Nacos
- 微信小程序基础
- unittest. Texttestrunner does not generate TXT test reports
猜你喜欢
Huawei mindspire open source internship machine test questions
Fe - wechat applet - Bluetooth ble development research and use
AWD学习
Name six schemes to realize delayed messages at one go
Pytest (2) mark function
ctf-web之练习赛
Pytest (1) case collection rules
FE - 微信小程序 - 蓝牙 BLE 开发调研与使用
CTF three count
Solution to the black screen of win computer screenshot
随机推荐
Promise中有resolve和无resolve的代码执行顺序
Code execution sequence with and without resolve in promise
[daily question 1] write a function to judge whether a string is the string after the rotation of another string.
Implement strstr() II
web自动化切换窗口时报错“list“ object is not callable
Alibaba cloud MFA binding Chrome browser
Pytest (1) case collection rules
20210306 reprint how to make TextEdit have background pictures
Virtualenv and pipenv installation
unittest.TextTestRunner不生成txt测试报告
CTF three count
看完有用的blog
Redis - hot key issues
Improve user experience defensive programming
Distributed transactions: the final consistency scheme of reliable messages
sprintf_ How to use s
NodeJs - Express 中间件修改 Header: TypeError [ERR_INVALID_CHAR]: Invalid character in header content
2020-9-23 QT的定时器Qtimer类的使用。
Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
Solution to the black screen of win computer screenshot