当前位置:网站首页>Introduction to dirty reading, unrepeatable reading and phantom reading
Introduction to dirty reading, unrepeatable reading and phantom reading
2022-04-23 14:52:00 【Top high school students】
stay MySQL Of the many storage engines , Only InnoDB Support transactions , All the transaction isolation levels mentioned here refer to InnoDB Transaction isolation level under .
MySQL It supports concurrent execution of multiple transactions . Otherwise, a transaction processing a request , When dealing with a person's request , Everything else is waiting , No one dares to use it MySQL As a database , Because the user experience is too bad , I guess it's going to hit the keyboard .
Since transactions can operate concurrently , Here are some questions : When a transaction writes data , Another transaction wants to read this row of data , What to do with ? A transaction is writing data , Another data should also write this line of data , How to deal with this conflict ?
Since transactions can operate concurrently , Here are some questions : When a transaction writes data , Another transaction wants to read this row of data , What to do with ? A transaction is writing data , Another data should also write this line of data , How to deal with this conflict ?
These are some of the problems caused by concurrent transactions . To be specific : Dirty reading 、 No repeated reading or phantom reading
Dirty reading
Dirty reading is when a transaction is accessing data , And the data has been modified , This modification has not yet been committed to the database , At this time , Another transaction also accesses this data , And then I used this data .
for example :
Zhang San's salary is 5000, Business A Change his salary to 8000, But the business A Not yet submitted .
meanwhile ,
Business B Reading Zhang San's salary , I read that Zhang San's salary is 8000.
And then ,
Business A Something goes wrong , and Roll back It's a matter of . Zhang San's salary is rolled back to 5000.
Last ,
Business B The read salary of Zhang San is 8000 The data is dirty , Business B Did a dirty reading .
It can't be read repeatedly
Within a transaction , Read the same data multiple times . Before the end of the business , Another transaction also accesses the same data . that , Between two reads in the first transaction , Due to the modification of the second transaction , So the data read by the first transaction twice may be different . This happens that the data read twice in a transaction is different , So it's called unrepeatable reading .
for example :
In the transaction A in , I read that Zhang San's salary is 5000, Operation not completed , The transaction has not been submitted .
meanwhile ,
Business B Change Zhang San's salary to 8000, And commit the transaction .
And then ,
In the transaction A in , Read Zhang San's salary again , At this time, the salary becomes 8000. The result of reading two times in a transaction does not result in , It leads to non repeatable reading .
Fantasy reading
A phenomenon that occurs when a transaction is not executed independently , For example, the first transaction modifies the data in a table , This modification involves all data rows in the table . meanwhile , The second transaction also modifies the data in this table , This modification is to insert a new row of data into the table . that , In the future, the user who operates on the first transaction will find out whether there are any modified data rows in the table , It's like an illusion .
for example :
The present salary is 5000 Of the employees 10 people , Business A Read all salaries as 5000 The number of people is 10 people .
here ,
Business B Insert a salary for 5000 The record of .
At this time ,
Business A Read the salary again as 5000 The employees' , Record as 11 people . At this time, unreal reading .
remind
The point of unrepeatable reading is to modify :
The same conditions , The data you read , Read it again and find that the value is different
The point of unreal reading is to add or delete :
The same conditions , The first 1 Time and number 2 The number of records read is not the same
版权声明
本文为[Top high school students]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231450328682.html
边栏推荐
- Vous ne connaissez pas encore les scénarios d'utilisation du modèle de chaîne de responsabilité?
- 剑指 Offer II 019. 最多删除一个字符得到回文(简单)
- Swift:Entry of program、Swift调用OC、@_silgen_name 、 OC 调用Swift、dynamic、String、Substring
- Contraction mapping theorem
- Leetcode153 - find the minimum value in the rotation sort array - array - binary search
- 牛客网数据库SQL实战详细剖析(26-30)
- Swift Protocol 关联对象 资源名称管理 多线程GCD 延迟 once
- 【NLP】HMM隐马尔可夫+维特比分词
- [detailed explanation of factory mode] factory method mode
- LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
猜你喜欢
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
Is asemi ultrafast recovery diode interchangeable with Schottky diode
[servlet] detailed explanation of servlet (use + principle)
Swift - literal, literal protocol, conversion between basic data types and dictionary / array
Redis主从同步
do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、
Progress in the treatment of depression
L'externalisation a duré quatre ans.
SVN详细使用教程
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
随机推荐
What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
L'externalisation a duré quatre ans.
LeetCode162-寻找峰值-二分-数组
Ali developed three sides, and the interviewer's set of combined punches made me confused on the spot
每日一题-LeetCode396-旋转函数-递推
Explain TCP's three handshakes in detail
pnpm安装使用
The difference between having and where in SQL
Don't you know the usage scenario of the responsibility chain model?
[untitled]
3、 Gradient descent solution θ
1N5408-ASEMI整流二极管1N5408
vscode中文插件不生效问题解决
【Proteus仿真】自动量程(范围<10V)切换数字电压表
Advanced application of I / O multiplexing: Processing TCP and UDP services at the same time
Unity_代码方式添加绑定按钮点击事件
I/O复用的高级应用:同时处理 TCP 和 UDP 服务
OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示
小红书 timestamp2 (2022/04/22)
[proteus simulation] automatic range (range < 10V) switching digital voltmeter