当前位置:网站首页>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
边栏推荐
- LeetCode每日一题(2316. Count Unreachable Pairs of Nodes in an Undirected Graph)
- Oracle installation enhancements error
- (3/8) method parameters of improper use of enumeration (2)
- 12、 Sort
- esp8266使用TF卡并读写数据(基于arduino)
- Leetcode daily questions (2316. count unreachable pairs of nodes in an undirected graph)
- 牛客网——华为题库(61~70)
- Unity uses mesh to realize real-time point cloud (II)
- Create an int type array with a length of 6. The values of the array elements are required to be between 1-30 and are assigned randomly. At the same time, the values of the required elements are diffe
- Mysql database transaction learning notes
猜你喜欢
Data association between two interfaces of postman
答案在哪里?action config/Interceptor/class/servlet
[4G/5G/6G专题基础-146]: 6G总体愿景与潜在关键技术白皮书解读-1-总体愿景
Unittest simple project
Regular matching starts with XXX and ends with XXX
VSCode+mingw64+cmake
Mysql数据库-锁-学习笔记
Zen - batch import test cases
Lesson 1: finding the minimum of a matrix
JS逆向教程第一发
随机推荐
Error: selenium common. exceptions. WebDriverException: Messag‘geckodriver‘ execute
信息安全实验三 :PGP邮件加密软件的使用
创建一个长度为6的int型数组,要求数组元素的值都在1-30之间,且是随机赋值。同时,要求元素的值各不相同。
Information Security Experiment 2: using x-scanner scanning tool
SAP MM STO单据的外向交货单创建后新加ITEM?
Jemter operation
ComputeShader
战略合作|SubQuery 成为章鱼网络浏览器的秘密武器
js逆向教程第二发-猿人学第一题
如何成为一名高级数字 IC 设计工程师(5-3)理论篇:ULP 低功耗设计技术精讲(下)
Cesium does not support 4490 problem solution and cesium modified source code packaging scheme
Upload taro pictures to Base64
JWT certification used in DRF
JS逆向教程第一发
**Grafana installation**
进程和线程的区别
Octopus future star won a reward of 250000 US dollars | Octopus accelerator 2022 summer entrepreneurship camp came to a successful conclusion
Where is the answer? action config/Interceptor/class/servlet
Entity of cesium data visualization (Part 1)
What is MD5