当前位置:网站首页>Mvcc principle in MySQL
Mvcc principle in MySQL
2022-06-29 04:41:00 【Feng 210】
Catalog
What is snapshot reading , And current reading ?
mvcc Implementation principle of ?
RC,RR Under the inoodb What's the difference ?
What is? mvcc?
MVCC, Full name Multi-Version Concurrency Control, Multi version concurrent control .MVCC It's a method of concurrency control , Generally in the database management system , Realize concurrent access to database , Implement transaction memory in programming language .
What is snapshot reading , And current reading ?
1、 The current reading
select lock in share mode( Shared lock ), select for update ; update, insert,delete( Exclusive lock ) These operations are all a current read
The current read is to read the latest version of the record , When reading, it is also necessary to ensure that other concurrent transactions cannot modify the current record , Will lock the read record
2、 Read the snapshot
Operation without locking (select) That's snapshot reading , Non blocking read without lock ;
The premise of snapshot read is that isolation level is not serial level , Snapshot reads at the serial level degrade to current reads ;
namely MVCC, It can be said that MVCC It's a variant of a line lock , But it's in many cases , Avoid lock operation , Lower the cost
The implementation of snapshot read is based on multi version concurrency control , Since it's based on multiple versions , That is to say, what the snapshot read may not be the latest version of the data , It could be the previous version of history
mvcc The role of ?
mvcc The function of is mainly in the multi-threaded environment , Improve database read and write performance , Solution reading ( Read the snapshot )- Lock free concurrency control for write problems .
mvcc Implementation principle of ?
mvcc The implementation principle of is through the hidden fields and undolog as well as readview Realized
Hide fields :
DB_TRX_ID
6 byte , Of the recently modified transaction id, Record the record created or last modified id.
DB_ROLL_PTR
7 byte , rollback pointer , Point to the previous version of this record for matching undolog, Point to the previous old version .
DB_ROW_ID
6 byte , Hidden primary key , If the data table has no primary key , that inodb It will automatically generate a 6 Bytes of row_id.
uodolog:
uodolog It is called rollback log , It means in progress delete,update,insert Log for easy rollback .
readview:
readview It is a view generated when a transaction performs a snapshot read operation , At the moment when the transaction performs snapshot reading , Will generate a snapshot of the current data system , Record and maintain the current active transactions id, Business id The value of is increasing .
readview Three global attributes in :
trx_list: A list of values , Used for maintenance readview Generate transactions that are active in the system at the time id
up_limit_id: Record trx_list Transactions in the list id The smallest id
low_limit_id:readview Generate the next transaction that the system has not yet allocated ID
mvcc Implementation process :
The following is a simulation diagram ( Suppose transaction one is id by 1, And so on )

The specific comparison rules are as follows :
1. Compare first DB_TRX_ID( Of the recently modified transaction id 6)< up_limit_id( Record trx_list Transactions in the list id The smallest id
1) , You can see DB_TRX_ID Records , If it is greater than or equal to, go to the next judgment .( obviously 6>1 Enter the second judgment )
2. Then judge DB_TRX_ID(6)>=low_limit_id( Generate the next transaction that the system has not yet allocated ID 7) , If greater than or equal to, it means DB_TRX_ID The location is recorded in readview Only after generation , So it must be invisible to the current transaction , If it is less than , Then proceed to the next judgment .(6<7 Means not readview Those that appear only after generation enter the next judgment )
3. Judge DB_TRX_ID Whether in an active transaction , If "in" means "in" readview The moment of creation , This transaction is still active , Not yet commit, The modified data cannot be seen in the current transaction , If not, it means that the transaction is readview It started before the generation commit, Then the modification result is visible .
RC,RR Under the inoodb What's the difference ?
Mainly because RC And RR Of readview Generation timing is different , stay RC Under the isolation mechanism of , Each snapshot read generates and gets the latest readview, and RR Is the first snapshot read in the transaction readview, After that readview It's all the same .
边栏推荐
- 仿真与烧录程序有哪几种方式?(包含常用工具与使用方式)
- The people's Bank of China printed and distributed the notice on supporting cross-border RMB settlement of new foreign trade formats
- Command pattern
- Observer pattern
- How to quickly install MySQL 5.7.17 under CentOS 6.5
- 网络设备设置/取消console口登陆单独密码
- Microsoft Pinyin IME personal preferences
- Airflow 2.2.3 containerized installation
- [wc2021] Fibonacci - number theory, Fibonacci sequence
- CTO and programmer were both sentenced because the crawler was out of control!
猜你喜欢

Daily practice - February 15, 2022
![[performance test] introduction and installation of JMeter](/img/8c/cc5dd3e7db02e084937c917cc71e5f.jpg)
[performance test] introduction and installation of JMeter

JVM_ 16_ Garbage collector

安捷伦数字万用表软件NS-Multimeter,实时数据采集数据自动保存

Mysql 中的 mvcc原理

波形记录仪MR6000的实时波形运算功能

To learn more about Yibo Hongmeng development

Redis cache penetration, cache breakdown, cache avalanche

Network device setting / canceling console port login separate password

没遇到过这三个问题都不好意思说用过Redis
随机推荐
从零到一,教你搭建「以文搜图」搜索服务(一)
How to create a subtype like relationship between two generic classes when the classes are generic related
Basic use of JSX
What is the method of connection query in MySQL
Decorator Pattern
Hantai oscilloscope software | Hantai oscilloscope upper computer software ns-scope, add measurement data arbitrarily
Gbase 8s must be a DBSA. Solution to failure to start due to path change
Airflow2.2.3 + efficiency + MySQL 8 build a robust distributed scheduling cluster
Research Report on the overall scale, major manufacturers, major regions, products and application segments of 5g modules of the Internet of things in the global market in 2022
MySQL subquery
Research Report on the overall scale, major manufacturers, major regions, product and application segmentation of GSM and GPRS modules in the global market in 2022
Blue Bridge Cup ruler method
The subnet of the pool cannot be overlapped with that of other pools.
Technical parameters of Tektronix DPO4104 digital fluorescence oscilloscope
Practical part: solving the function conflict between swagger and user-defined parameter parser
人民银行印发《关于支持外贸新业态跨境人民币结算的通知》
It is said on the Internet that a student from Guangdong has been admitted to Peking University for three times and earned a total of 2million yuan in three years
BERT和ViT简介
An efficient flutter hybrid stack management scheme with zero intrusion, you deserve it!
Rapid development project -vscode plug-in