当前位置:网站首页>Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
2022-07-03 15:11:00 【Miss, do you fix the light bulb】
First put a mind map , I can't help but use the free version of the template , After all, I still eat soil every day , No money for membership . Understand this picture , In fact, for innodb You have mastered the characteristics of the storage engine .
One 、mysql Common storage engines
myisam: Unsupported transaction , Table locks . Data files and index files are separated , Files can be compressed
innnodb: Support transactions , Row lock ( It can be upgraded to table lock ), Support primary and foreign keys .
Today's main discussion innodb Storage engine for , Don't add more to others .
Two 、 The level of isolation of things
First, find a picture on the Internet , Come to a conclusion , stay mysql Of innodb Search engine , default RR Repeatable reading level , It can solve unreal reading . The picture is not accurate , Marked 
In the figure, there are explanations for each case , Here I quickly skim over in a simple and clear way
Dirty reading : Business A Read transaction B Uncommitted data A read B update Not submitted
It can't be read repeatedly : Business A Read 2 Time ,2 The secondary data is inconsistent A read 2 Time ,B update Has been submitted
Fantasy reading :A Range query read 2 Time ,B insert after ( Critical lock : Opening left and closing right can solve , You can add a write lock to the current range search , Will result in the inability to insert data , Not twice
The range lookup result set is inconsistent )
3、 ... and 、 Thinking based on isolation level
Ordinary scenes , Concurrency or low business requirements : Our query statements are basically fast illumination MVCC
In this concurrent scenario , Ensure isolation , Then you can only lock it , Use the mutex of lock to control ,LBCC The current reading .
1. Use locks lbcc The current reading
insert
delect
update
// Row lock classification
select .....for update Write lock
select .....lock in share mode Read the lock
2. snapshot MVCC
ordinary select Statements are snapshots
Four 、innodb How to realize the next lock , Why can critical lock solve unreal reading ?
1.innnodb By default, an uplink lock is added to the index , If the query condition is not index , Sorry, it will be upgraded to table lock
2. Implementation and classification of row lock :
Record locks :
1. When sql Search the index data according to the method of finding equivalent matching
2. Hit data
Clearance lock : Left open right open
1. When sql Search the index data according to the method of finding equivalent matching
2. When the data does not hit
Critical lock : Left open right closed
1. When SQL When performing data retrieval on the index by search range
2. And when there is data hit
This is the end of the additional description of the figure , If you have any questions or different opinions, you are welcome to learn .
So far, we are talking about the extended locking mechanism in the isolation level of things
But I still want to share the communication behavior of things , Especially a very common scene , In the same class , Transaction method A Call non transactional methods B, The transaction is effective , And whether it's A still B If an exception occurs in the method, the transaction will be rolled back .
Have time to write code to verify , Here is a conclusion written by the author . You can reprint and view https://blog.csdn.net/qq_39355504/article/details/109893065
边栏推荐
猜你喜欢

Yolov5系列(一)——网络可视化工具netron
![[pytorch learning notes] datasets and dataloaders](/img/c0/9cd539caff34db3cccc44505bbe3c5.png)
[pytorch learning notes] datasets and dataloaders
![Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)](/img/cd/2e4f5884d034ff704809f476bda288.png)
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)

5-1 blocking / non blocking, synchronous / asynchronous
![[opengl] advanced chapter of texture - principle of flowmap](/img/dd/6208122fcc578caaf098301b185e03.jpg)
[opengl] advanced chapter of texture - principle of flowmap

Construction of operation and maintenance system

How does vs+qt set the software version copyright, obtain the software version and display the version number?
![[transform] [NLP] first proposed transformer. The 2017 paper](/img/33/f639ab527d5adedfdc39f8d8117c3e.png)
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team

Incluxdb2 buckets create database

What is machine reading comprehension? What are the applications? Finally someone made it clear
随机推荐
Kubernetes带你从头到尾捋一遍
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)
Tencent internship interview sorting
[combinatorics] permutation and combination (set permutation, step-by-step processing example)
TPS61170QDRVRQ1
Global and Chinese markets for flexible chips 2022-2028: Research Report on technology, participants, trends, market size and share
Remote server background hangs nohup
Global and Chinese markets for indoor HDTV antennas 2022-2028: Research Report on technology, participants, trends, market size and share
Stress test WebService with JMeter
Global and Chinese market of postal automation systems 2022-2028: Research Report on technology, participants, trends, market size and share
视觉上位系统设计开发(halcon-winform)-1.流程节点设计
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
mysql innodb 存储引擎的特性—行锁剖析
Kubernetes 进阶训练营 Pod基础
What is label encoding? How to distinguish and use one hot encoding and label encoding?
Série yolov5 (i) - - netron, un outil de visualisation de réseau
【可能是全中文网最全】pushgateway入门笔记
C string format (decimal point retention / decimal conversion, etc.)
Dataframe returns the whole row according to the value
Solve the problem that pushgateway data will be overwritten by multiple push