当前位置:网站首页>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
边栏推荐
- Pytoch deep learning and target detection practice notes
- Didi off the shelf! Data security is national security
- Centos7 deployment sentry redis (with architecture diagram, clear and easy to understand)
- 复合类型(自定义类型)
- 北京共有产权房出租新规实施的租赁案例
- Web server code parsing - thread pool
- el-switch 赋值后状态不变化
- The first character of leetcode sword offer that only appears once (12)
- Pytorch深度学习和目标检测实战笔记
- Class part2
猜你喜欢
Kubernetes 进阶训练营 Pod基础
[wechat applet] wxss template style
What is one hot encoding? In pytoch, there are two ways to turn label into one hot coding
There are links in the linked list. Can you walk three steps faster or slower
Yolov5系列(一)——網絡可視化工具netron
Yolov5系列(一)——网络可视化工具netron
解决pushgateway数据多次推送会覆盖的问题
Functional modules and application scenarios covered by the productization of user portraits
【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器
视觉上位系统设计开发(halcon-winform)-4.通信管理
随机推荐
What is one hot encoding? In pytoch, there are two ways to turn label into one hot coding
Pytoch deep learning and target detection practice notes
Kubernetes vous emmène du début à la fin
零拷贝底层剖析
[engine development] in depth GPU and rendering optimization (basic)
Global and Chinese market of lighting control components 2022-2028: Research Report on technology, participants, trends, market size and share
.NET六大设计原则个人白话理解,有误请大神指正
[opengl] advanced chapter of texture - principle of flowmap
复合类型(自定义类型)
App全局异常捕获
Global and Chinese market of air cargo logistics 2022-2028: Research Report on technology, participants, trends, market size and share
Matplotlib drawing label cannot display Chinese problems
Global and Chinese market of solder bars 2022-2028: Research Report on technology, participants, trends, market size and share
Kubernetes带你从头到尾捋一遍
基于SVN分支开发模式流程浅析
Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
Web server code parsing - thread pool
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
[engine development] rendering architecture and advanced graphics programming
Devaxpress: range selection control rangecontrol uses