当前位置:网站首页>Mvcc (multi version concurrency control)
Mvcc (multi version concurrency control)
2022-04-23 07:41:00 【cqwoniu】
1、 Introduce
MVCC, Multi version concurrency control , Problem solved : Judge whether the current transaction is visible to a line of records ( Can I read the latest result value just modified ), Here's a visibility algorithm , Before introducing the algorithm , Let's first add two concepts and MVCC The underlying principle of .
Two concepts :
- The current reading : Read the latest version of the data , Always read the latest data , Such as the following sql sentence :
a、select……lock in share mode
b、select……for uodate
c、update……
d、delete……
e、insert…… - Read the snapshot : What is read is the record of historical version ,sql Statements such as select……
Underlying principle :
MVCC Including three parts :
-
The first part is hidden fields , Each row of records in the table will have several hidden fields invisible to the user ,
- DB_TRX_ID: The transaction that created or last modified the record id;
- DB_ROW_ID : Hide primary key ( If no primary key is set , And there is no unique exception in the table Generated when the field is empty and of integer type
- DB_ROW_PTR: rollback pointer , Point to the previous version of the record
-
The second part
- undolog: Rollback log , Before the modification record of the transaction , The original value of the record will be saved first and then modified , So that errors in the modification process can restore the original value or other transaction reads . When different transactions modify a record , Will cause the record to undolog Form a line table , That's the list , The head of the linked list is the latest record , And the chain tail is the earliest historical record .
-
The third part
- readview : The read view generated by the transaction during snapshot reading , It also has three fields :
1. trx_list: System active transactions id
2. up_limit_id: The smallest transaction in the list id
3. low_limit_id: Of the next transaction that has not been allocated by the system id
- readview : The read view generated by the transaction during snapshot reading , It also has three fields :
Next , We introduce the visibility algorithm rules :
- Compare first DB_TRX_ID<UP_LIMIT_ID, If it is less than , Then the current transaction can see DBTRX_ID Records ; If greater than or equal to , Then proceed to the next judgment
- Then judge DB_TRX_ID>=LOW_LIMIT_ID, If greater than or equal to , Then represent DB_TRX_ID The record is in READ_VIEW It only appears after generation , Then it must not be visible to transactions ; If it is less than , Then go to the next step to judge
- Judge DB_TRX_ID Is in an active transaction , If in , What's on behalf of me READ_VIEW Generation time , This transaction is still active , Not yet commit Modified data , The current transaction is also invisible , If not , It means that this transaction is in READ_VIEW It started before the generation commit, Then the result of the modification is visible .
版权声明
本文为[cqwoniu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230622032086.html
边栏推荐
猜你喜欢
反思 | 事件总线的局限性,组件化开发流程中通信机制的设计与实现
菜菜的刷题日记 | 蓝桥杯 — 十六进制转八进制(纯手撕版)附进制转换笔记
反思 | Android 音视频缓存机制的系统性设计
组合数求解与(扩展)卢卡斯定理
页面实时显示当前时间
vim+ctags+cscpope开发环境搭建指南
Discussion on arrow function of ES6
Take you to travel in space, and American photography technology provides comprehensive technical support for aerospace creative applet
反思|开启B站少女心模式,探究APP换肤机制的设计与实现
SAP PI/PO rfc2RESTful 發布rfc接口為RESTful示例(Proxy間接法)
随机推荐
(扩展)BSGS与高次同余方程
Design optimization of MySQL database
12.约束
Lead the industry trend with intelligent production! American camera intelligent video production platform unveiled at 2021 world Ultra HD Video Industry Development Conference
王者荣耀-unity学习之旅
Source Insight 4.0常见问题
Learn to use search engines
莫比乌斯反演
Transformer的pytorch实现
关于素数的不到100个秘密
菜菜的并发编程笔记 |(五)线程安全问题以及Lock解决方案
手游性能优化
Two threads print odd and even numbers interactively
积性函数与迪利克雷卷积
【TED系列】一个习惯是如何改变我的一生
Applet newline character \ nfailure problem resolution - Daily pit stepping
[self motivation series] what really hinders you?
每日一题 | 曾被反转链表支配的恐惧
Reflect on the limitations of event bus and the design and implementation of communication mechanism in component development process
直观理解熵