当前位置:网站首页>Mvcc (multi version concurrency control)
Mvcc (multi version concurrency control)
2022-04-23 07:41:00 【cqwoniu】
1、 Introduce
MVCC, Multi version concurrency control , Problem solved : Judge whether the current transaction is visible to a line of records ( Can I read the latest result value just modified ), Here's a visibility algorithm , Before introducing the algorithm , Let's first add two concepts and MVCC The underlying principle of .
Two concepts :
- The current reading : Read the latest version of the data , Always read the latest data , Such as the following sql sentence :
a、select……lock in share mode
b、select……for uodate
c、update……
d、delete……
e、insert…… - Read the snapshot : What is read is the record of historical version ,sql Statements such as select……
Underlying principle :
MVCC Including three parts :
-
The first part is hidden fields , Each row of records in the table will have several hidden fields invisible to the user ,
- DB_TRX_ID: The transaction that created or last modified the record id;
- DB_ROW_ID : Hide primary key ( If no primary key is set , And there is no unique exception in the table Generated when the field is empty and of integer type
- DB_ROW_PTR: rollback pointer , Point to the previous version of the record
-
The second part
- undolog: Rollback log , Before the modification record of the transaction , The original value of the record will be saved first and then modified , So that errors in the modification process can restore the original value or other transaction reads . When different transactions modify a record , Will cause the record to undolog Form a line table , That's the list , The head of the linked list is the latest record , And the chain tail is the earliest historical record .
-
The third part
- readview : The read view generated by the transaction during snapshot reading , It also has three fields :
1. trx_list: System active transactions id
2. up_limit_id: The smallest transaction in the list id
3. low_limit_id: Of the next transaction that has not been allocated by the system id
- readview : The read view generated by the transaction during snapshot reading , It also has three fields :
Next , We introduce the visibility algorithm rules :
- Compare first DB_TRX_ID<UP_LIMIT_ID, If it is less than , Then the current transaction can see DBTRX_ID Records ; If greater than or equal to , Then proceed to the next judgment
- Then judge DB_TRX_ID>=LOW_LIMIT_ID, If greater than or equal to , Then represent DB_TRX_ID The record is in READ_VIEW It only appears after generation , Then it must not be visible to transactions ; If it is less than , Then go to the next step to judge
- Judge DB_TRX_ID Is in an active transaction , If in , What's on behalf of me READ_VIEW Generation time , This transaction is still active , Not yet commit Modified data , The current transaction is also invisible , If not , It means that this transaction is in READ_VIEW It started before the generation commit, Then the result of the modification is visible .
版权声明
本文为[cqwoniu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230622032086.html
边栏推荐
猜你喜欢

Nacos / sentinel gateway current limiting and grouping (code)

Reflection on the systematic design of Android audio and video caching mechanism

vim+ctags+cscpope开发环境搭建指南

Take you to travel in space, and American photography technology provides comprehensive technical support for aerospace creative applet

自定义时间格式(YYYY-MM-DD HH:mm:ss 星期X)

如何SQL 语句UNION实现当一个表中的一列内容为空时则取另一个表的另一列

Lead the industry trend with intelligent production! American camera intelligent video production platform unveiled at 2021 world Ultra HD Video Industry Development Conference

组合数求解与(扩展)卢卡斯定理

On BFC (block formatting context)

菜菜的并发编程笔记 |(五)线程安全问题以及Lock解决方案
随机推荐
公共依赖模块common的处理
[2020WC Day2]F.采蘑菇的克拉莉丝(子树和查询、轻重儿子思想)
5.SQL99标准:内连接和外连接
对STL容器的理解
技能点挖坑
菜菜的刷题日记 | 238.除自身以外数组的乘积
反思 | Android 音视频缓存机制的系统性设计
Educational Codeforces Round 81 (Rated for Div. 2)
(扩展)BSGS与高次同余方程
7.子查询
理解补码的要点
VScode
F-牛妹的苹果树(直径合并)
LATEX使用
9.常用函数
直观理解熵
Mysql 数据库从设计上的优化
VIM使用
[hdu6868]Absolute Math(推式子+莫比乌斯反演)
手游性能优化