当前位置:网站首页>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
边栏推荐
- Difference between process and thread
- Pytest installation (command line installation)
- js逆向教程第二发-猿人学第一题
- Lecture 1: stack containing min function
- Add new item after the outbound delivery order of SAP mm sto document is created?
- esp8266使用TF卡并读写数据(基于arduino)
- 如何成为一名高级数字 IC 设计工程师(5-3)理论篇:ULP 低功耗设计技术精讲(下)
- Jenkins modifies the system time
- Information Security Experiment 1: implementation of DES encryption algorithm
- The configuration and options of save actions are explained in detail, and you won't be confused after reading it
猜你喜欢

VSCode+mingw64

Error: selenium common. exceptions. WebDriverException: Messag‘geckodriver‘ execute

Using JWT to realize login function

Mysql database index study notes

Difference between interface iterator and iteratable

Mysql数据库-锁-学习笔记

Vs2013 generate solutions super slow solutions

Jemter operation

嵌套(多级)childrn路由,query参数,命名路由,replace属性,路由的props配置,路由的params参数

nlohmann json
随机推荐
答案在哪里?action config/Interceptor/class/servlet
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
NETCORE 3.1 solves cross domain problems
Information Security Experiment 2: using x-scanner scanning tool
12、 Sort
其实特简单,教你轻松实现酷炫的数据可视化大屏
Dynamics 365Online ApplicationUser创建方式变更
二叉树高频题型
信息安全实验二 :使用X-SCANNER扫描工具
Strategic cooperation subquery becomes the secret weapon of Octopus web browser
asp. How to call vb DLL function in net project
H5 web player easyplayer How does JS realize live video real-time recording?
VSCode+mingw64
Data association between two interfaces of postman
esp8266使用TF卡并读写数据(基于arduino)
golang select机制和超时问题怎么解决
H5网页播放器EasyPlayer.js如何实现直播视频实时录像?
Jemter operation
Redis common commands
Mysql database index study notes