当前位置:网站首页>Elaborate on MySQL mvcc multi version control
Elaborate on MySQL mvcc multi version control
2022-07-07 09:36:00 【qq_ five hundred and forty million six hundred and sixteen thou】
This paper mainly solves the problem :
1:MVCC The specific meaning of
2:mysql in MVCC How is it realized
MVCC Multi version control Before you say this, you need to know a few things
One : Business ID
a:mysql There will be ID( Only when the table is changed for the first time , Otherwise 0) Assigned transactions id Is the only self increasing ;
b:mysql Each record in the table will have a trx_id Hide columns , It records the corresponding transaction when the current data is modified ID( There's another. roll_pointer Hide columns It refers to when it is modified undo logging , It's the data of the last version )
Two :undo journal
a: When each record is modified, a undo journal , Logging is similar to recording data, that is, it saves the data information before being modified , Generally, only the modified columns are recorded
b: After a record is modified many times , Each version undo The log roll_pointer It will string the records modified many times into a version linked list ( Simply put, every undo The journal also has roll_pointer The column records the previous undo journal )
Here's the last picture
3、 ... and : Isolation level
sql altogether 4 Isolation levels Read uncommitted , Read submitted , Repeatable , Serialization ;
Here read unsubmitted The two isolation levels of serialization are to directly read the latest version , There is no such thing as multiple versions ;
So what is discussed here MVCC It usually refers to :
For the use of READ COMMITTED( Read submitted ) and REPEATABLE READ( Repeatable ) For isolation level transactions , You must ensure that you read the modified records of the committed transactions ; That is, if another transaction has modified the record but has not yet committed , You cannot directly read the latest version of the record . The core issue is You need to determine which version in the version chain is accessible to the current transaction
Solution :ReadView, Readable view ( Consistency view )
This ReadView It mainly includes 4 A more important content :
• m_ids : It's generating ReadView when , All transactions of active read / write transactions in the current system id list
• min_trx_id: It's generating ReadView when , The smallest of the active read / write transactions in the current system id, It's just m_ids Minimum of .
• max_trx_id : It's generating ReadView when , The transaction that the system should assign to the next transaction id value ( No m_ids Maximum of , It's the next one )
• creator_trx_id : Generate this ReadView The business of id
Find process :( Take the read committed isolation level as an example )
When accessing a record Just follow the steps below to determine whether a version of the record is visible .
**1:** Get the system information and generate the record readView
**2:** Find the latest version of this record , And get its trx_id value
**3:** Judge trx_id Whether the value is included in ReadView Of m_ids in ( Priority will be given here creator_trx_id,min_trx_id,max_trx_id To judge , See the notes below for details )
If it exists, the version data is unreadable , Find the previous version directly from the version chain and continue to judge ;
If it does not exist, it means that the version data is readable , Directly return this version data ;
// notes
a: If the accessed version of trx_id Property value and ReadView Medium creator_trx_id Same value , It means that the current transaction is accessing its own modified records , So the data of this version is readable , Go straight back to ;
b: If the accessed version of trx_id Attribute value is small ReadView Medium min_trx_id value , Indicates that the transaction generating this version generates ReadView Submitted , So this version can be accessed by the current transaction , Directly return the version data ;
c: If the accessed version of trx_id Property value is greater than or equal to ReadView Medium max_trx_id Indicates that the transaction generating this version is generated in the current event ReadView It's only opened after , So this version cannot be accessed by the current transaction , Continue to judge trx_id Whether it is included in m_ids in ;
Last :
For the implementation of repeatable read isolation level, you only need to control ReadView The generation time of
In the read submitted isolation level, each query will generate ReadView , The repeatable read only needs to be generated when the transaction is first read ReadView that will do
边栏推荐
- Yapi test plug-in -- cross request
- Final keyword
- 信息安全实验四:Ip包监视程序实现
- 牛客网——华为题库(61~70)
- Entity of cesium data visualization (Part 1)
- 章鱼未来之星获得25万美金奖励|章鱼加速器2022夏季创业营圆满落幕
- Colorbar of using vertexehelper to customize controls (II)
- # Arthas 简单使用说明
- Some pit avoidance guidelines for using Huawei ECS
- H5 web player easyplayer How does JS realize live video real-time recording?
猜你喜欢
NATAPP内网穿透
Oracle安装增强功能出错
What is MD5
Jmeters use
Postman data driven
Integer or int? How to select data types for entity classes in ORM
【SVN】SVN是什么?怎么使用?
[bw16 application] Anxin can realize mqtt communication with bw16 module / development board at instruction
Pycharm importing third-party libraries
【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
随机推荐
ViewPager2和VIewPager的区别以及ViewPager2实现轮播图
Schema-validation: wrong column type encountered in column XXX in table XXX
Information Security Experiment 4: implementation of IP packet monitoring program
4、 Fundamentals of machine learning
Zen - batch import test cases
Unity shader (learn more about vertex fragment shaders)
Loxodonframework quick start
Leetcode daily questions (2316. count unreachable pairs of nodes in an undirected graph)
Upload taro pictures to Base64
What is MD5
Connecting mobile phone with ADB
Jmeters use
**Grafana installation**
Unity shader (data type in cghlsl)
scrapy爬虫mysql,Django等
如何使用clipboard.js库实现复制剪切功能
Impression notes finally support the default markdown preview mode
[4G/5G/6G专题基础-147]: 6G总体愿景与潜在关键技术白皮书解读-2-6G发展的宏观驱动力
如何成为一名高级数字 IC 设计工程师(5-2)理论篇:ULP 低功耗设计技术精讲(上)
Interface test API case, data and interface separation