当前位置:网站首页>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
边栏推荐
- H5网页播放器EasyPlayer.js如何实现直播视频实时录像?
- Postman setting environment variables
- How does mongodb realize the creation and deletion of databases, the creation of deletion tables, and the addition, deletion, modification and query of data
- Unity shader (learn more about vertex fragment shaders)
- Connecting mobile phone with ADB
- 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
- 【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
- Unity shader (to achieve a simple material effect with adjustable color attributes only)
- [SVN] what is SVN? How do you use it?
- JMeter JDBC batch references data as input parameters (the simplest method for the whole website)
猜你喜欢
MongoDB怎么实现创建删除数据库、创建删除表、数据增删改查
软件建模与分析
Entity of cesium data visualization (Part 1)
[bw16 application] Anxin can realize mqtt communication with bw16 module / development board at instruction
Error: selenium common. exceptions. WebDriverException: Messag‘geckodriver‘ execute
信息安全实验三 :PGP邮件加密软件的使用
JWT certification used in DRF
印象笔记终于支持默认markdown预览模式
Mysql database transaction learning notes
Mysql:select ... for update
随机推荐
Unittest simple project
Zen - batch import test cases
答案在哪里?action config/Interceptor/class/servlet
The use of recycling ideas
嵌套(多级)childrn路由,query参数,命名路由,replace属性,路由的props配置,路由的params参数
Unity3d interface is embedded in WPF interface (mouse and keyboard can respond normally)
【BW16 应用篇】安信可BW16模组/开发板AT指令实现MQTT通讯
Unity shader (pass user data to shader)
Data association between two interfaces of postman
进程和线程的区别
浏览器中如何让视频倍速播放
Schema-validation: wrong column type encountered in column XXX in table XXX
4、 Fundamentals of machine learning
flinkcdc 用sqlclient可以指定mysqlbinlog id执行任务吗
[4g/5g/6g topic foundation-146]: Interpretation of white paper on 6G overall vision and potential key technologies-1-overall vision
nlohmann json
在EXCEL写VBA连接ORACLE并查询数据库中的内容
MongoDB怎么实现创建删除数据库、创建删除表、数据增删改查
Regular matching starts with XXX and ends with XXX
Mysql database lock learning notes