当前位置:网站首页>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
边栏推荐
- do(Local scope)、初始化器、内存冲突、Swift指针、inout、unsafepointer、unsafeBitCast、successor、
- epoll 的EPOLLONESHOT 事件———实例程序
- 1990年1月1日是星期一,定义函数date_to_week(year,month,day),实现功能输入年月日后返回星期几,例如date_to_week(2020,11,1),返回:星期日。 提示:
- GIS数据处理-cesium中模型位置设置
- Swift - Literal,字面量协议,基本数据类型、dictionary/array之间的转换
- 脏读、不可重复读和幻读介绍
- Vous ne connaissez pas encore les scénarios d'utilisation du modèle de chaîne de responsabilité?
- Achievements in science and Technology (21)
- 填充每个节点的下一个右侧节点指针 II [经典层次遍历 | 视为链表 ]
- Frame synchronization implementation
猜你喜欢
【无标题】
LeetCode151-颠倒字符串中的单词-字符串-模拟
Svn detailed use tutorial
分享 20 个不容错过的 ES6 的技巧
Introduction to Arduino for esp8266 serial port function
GIS数据处理-cesium中模型位置设置
Model location setting in GIS data processing -cesium
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
8.4 循环神经网络从零实现
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
随机推荐
How do I open the win10 startup folder?
ASEMI整流模块MDQ100-16在智能开关电源中的作用
[jz46 translate numbers into strings]
OC 转 Swift 条件编译、标记、宏、 Log、 版本检测、过期提示
[servlet] detailed explanation of servlet (use + principle)
L'externalisation a duré quatre ans.
科技的成就(二十一)
PCIe X1 插槽的主要用途是什么?
DVWA之暴力破解(Brute Force)Low-->high
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
[NLP] HMM hidden Markov + Viterbi word segmentation
大文件如何快速上传?
Svn detailed use tutorial
Swift - Literal,字面量协议,基本数据类型、dictionary/array之间的转换
raised exception class EAccexxViolation with ‘Access violation at address 45EFD5 in module 出错
Explain TCP's three handshakes in detail
Comment eolink facilite le télétravail
LeetCode165-比较版本号-双指针-字符串
What is the main purpose of PCIe X1 slot?
Is asemi ultrafast recovery diode interchangeable with Schottky diode