当前位置:网站首页>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
边栏推荐
- 视觉上位系统设计开发(halcon-winform)-5.相机
- Kubernetes帶你從頭到尾捋一遍
- 阿特拉斯atlas扭矩枪 USB通讯教程基于MTCOM
- High quality workplace human beings must use software to recommend, and you certainly don't know the last one
- 视觉上位系统设计开发(halcon-winform)-4.通信管理
- Search in the two-dimensional array of leetcode sword offer (10)
- Tensor ellipsis (three points) slice
- 运维体系的构建
- Using Tengine to solve the session problem of load balancing
- 视觉上位系统设计开发(halcon-winform)-1.流程节点设计
猜你喜欢

什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用

Chapter 04_ Logical architecture

Yolov5系列(一)——網絡可視化工具netron

Idea does not specify an output path for the module
![[ue4] cascading shadow CSM](/img/83/f4dfda3bd5ba0172676c450ba7693b.jpg)
[ue4] cascading shadow CSM

【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer

Functional modules and application scenarios covered by the productization of user portraits

Basic SQL tutorial

Influxdb2 sources add data sources

Byte practice surface longitude
随机推荐
Centos7 deployment sentry redis (with architecture diagram, clear and easy to understand)
[combinatorics] permutation and combination (set permutation, step-by-step processing example)
Explanation of time complexity and space complexity
XWiki安装使用技巧
.NET六大设计原则个人白话理解,有误请大神指正
视觉上位系统设计开发(halcon-winform)-2.全局变量设计
Use of Tex editor
TPS61170QDRVRQ1
Nppexec get process return code
Global and Chinese markets for infrared solutions (for industrial, civil, national defense and security applications) 2022-2028: Research Report on technology, participants, trends, market size and sh
Mmdetection learning rate and batch_ Size relationship
4-24--4-28
Dataframe returns the whole row according to the value
406. Reconstruct the queue according to height
【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer
基于SVN分支开发模式流程浅析
5.2-5.3
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
视觉上位系统设计开发(halcon-winform)-4.通信管理
[ue4] material and shader permutation