当前位置:网站首页>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 .
边栏推荐
- Iterator pattern
- Hantai oscilloscope software | Hantai oscilloscope upper computer software ns-scope, add measurement data arbitrarily
- JVM_ 16_ Garbage collector
- CTO and programmer were both sentenced because the crawler was out of control!
- Developer scheme · environmental monitoring equipment (Xiaoxiong school IOT development board) connected to graffiti IOT development platform
- 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
- 044. (2.13) add value to yourself
- [C language] start a thread
- To learn more about Yibo Hongmeng development
- Observer pattern
猜你喜欢

LabVIEW显示Unicode字符

Seattention channel attention mechanism

如何创建 robots.txt 文件?

Daily practice - February 15, 2022

泰克DPO4104数字荧光示波器技术参数
![[结构力学] 结点承载下影响线与直接承载下影响线不同的原因](/img/a6/fce0bb29cc5c84bc0ef20501617e06.png)
[结构力学] 结点承载下影响线与直接承载下影响线不同的原因

BERT和ViT简介

Complete collection of necessary documents for project management: you can't write these 14 project documents yet?

【HackTheBox】dancing(SMB)

How to create robots Txt file?
随机推荐
docker 创建的 mysql8 怎么改密码
The virtual machine MySQL cannot be connected to the local computer
Real time waveform calculation function of Waveform Recorder mr6000
Cucumber test practice
网络设备设置/取消console口登陆单独密码
Technical parameters of Tektronix DPO4104 digital fluorescence oscilloscope
20年秦皇岛D - Exam Results(二分+思维,附易错数据)
Five thousand years of China
[Verilog quick start of Niuke network question brushing series] ~ asynchronous reset Series T trigger
043. (2.12) what will happen if you become enlightened?
EEG signal processing - wavelet transform series
笔记本访问台式机的共享磁盘
Quelles sont les méthodes de simulation et de gravure des programmes? (comprend les outils communs et la façon dont ils sont utilisés)
Actual combat! Another opening method of magic modified swagger and knife4j
Live broadcast appointment AWS data everywhere series activities
Open source demo| you draw and I guess -- make your life more interesting
Gocd is good, but talk about Jenkins
What exactly does GCC's -Wpsabi option do? What are the implications of supressing it?
Multi machine LAN office artifact rustdesk use push!!!
Rapid development project -vscode plug-in