当前位置:网站首页>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
边栏推荐
- 十二、排序
- 【云原生】DevOps(一):DevOps介绍及Code工具使用
- Entity of cesium data visualization (Part 1)
- SAP MM STO单据的外向交货单创建后新加ITEM?
- Mysql database lock learning notes
- Strategic cooperation subquery becomes the secret weapon of Octopus web browser
- Unity shader (to achieve a simple material effect with adjustable color attributes only)
- 牛客网——华为题库(61~70)
- Binary tree high frequency question type
- Unity uses mesh to realize real-time point cloud (I)
猜你喜欢
Zen - batch import test cases
Error: selenium common. exceptions. WebDriverException: Messag‘geckodriver‘ execute
Unity3d interface is embedded in WPF interface (mouse and keyboard can respond normally)
Esp8266 uses TF card and reads and writes data (based on Arduino)
How to speed up video playback in browser
VSCode+mingw64+cmake
STM32 and motor development (from stand-alone version to Networking)
细说Mysql MVCC多版本控制
Unity shader (to achieve a simple material effect with adjustable color attributes only)
Netease Cloud Wechat applet
随机推荐
What development models did you know during the interview? Just read this one
Pycharm create a new file and add author information
Octopus future star won a reward of 250000 US dollars | Octopus accelerator 2022 summer entrepreneurship camp came to a successful conclusion
Information Security Experiment 1: implementation of DES encryption algorithm
软件建模与分析
Kubernetes cluster capacity expansion to add node nodes
【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
Mysql:select ... for update
Liunx command
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
shake数据库中怎么使用Mongo-shake实现MongoDB的双向同步啊?
Strategic cooperation subquery becomes the secret weapon of Octopus web browser
Using JWT to realize login function
Huawei HCIP - datacom - Core 03 jours
asp. How to call vb DLL function in net project
Unity shader (basic concept)
十二、排序
四、机器学习基础
Oracle installation enhancements error
esp8266使用TF卡并读写数据(基于arduino)