当前位置:网站首页>MySQL isolation level
MySQL isolation level
2022-04-23 07:41:00 【cqwoniu】
One 、 Four characteristics of transactions
The isolation level of the transaction is ACID, That is atomicity 、 Uniformity 、 Isolation, 、 persistence .
1、 Atomicity
Atomicity means that the operation of the whole transaction is either committed successfully , Either all failures roll back .
2、 Uniformity
Consistency means that the database always changes from one consistent state to another consistent state , If the transaction is not committed , The changes made will not be saved to the database .
3、 Isolation,
Changes made by a transaction are made before the final submission , Is invisible to other transactions .
4、 persistence
Once the transaction is committed , The changes made will be permanently saved to the database .
Realized ACID The database of , Usually stronger cpu Processing power and more memory and more disk space .
Two 、 If there is no isolation , What will happen ?
1、 Dirty reading
| Business A | Business B |
|---|---|
| Open transaction A | |
| Open transaction B | |
| The query balance is 100 | |
| Increase balance to 150 | |
| The query balance is 150 |
Why is it dirty reading , Because no submission , If you roll back , Then the data read at this time is just a mirage .
2、 It can't be read repeatedly
| Business A | Business B |
|---|---|
| Open transaction A | |
| Open transaction B | |
| The query balance is 100 | |
| Increase balance to 150 | |
| The query balance is 100 | |
| Commit transaction | |
| The query balance is 150 |
Refers to a transaction scope , Query a data multiple times , But got different results .
Between two reads in the first transaction , Due to the modification of the second transaction , The data read by the first transaction twice may be different .
3、 Fantasy reading
| Business A | Business B |
|---|---|
| Open transaction A | |
| Open transaction B | |
| Inquire about id<3 The records of 3 strip | |
| Add a id=2 The record of | |
| Commit transaction | |
| Inquire about id<3 There are four records |
Another example is business T1 A data item is removed from all rows in a table “1” It is amended as follows “2” The operation of , When the transaction T2 Another row of data item is inserted into this table, which is “1” The data of , And submit it to the database . And operating transactions T1 If the user views the data that has just been modified , Will you find the data or 1, Actually this row is from the transaction T2 Added in , It's like hallucinating , This is where the phantom reading occurs .
Unreal reading and non repeatable reading are both read and submitted data , But unreal reading is aimed at a batch of data , Non repeatable reading is for a row of data .
3、 ... and 、 The isolation level of the transaction
1、 Uncommitted read
Changes in transactions , Even if it's not submitted , It's also visible to other things , Transactions can read uncommitted data , Uncommitted reading cannot avoid any of the above problems .
2、 Read submitted
When a transaction begins , You can only see the changes made by the submitted firm . Avoid dirty reading .
3、 Repeatable
In the same business , The result of multiple reads is the same . It can avoid dirty reading and repeatable reading , But unreal reading cannot be avoided .
4、 Serialization
Is the highest isolation level , Force transactions to execute serially , Avoid unreal reading 、 It can't be read repeatedly 、 Dirty reading problem , The serial will lock each row of data , Therefore, it may cause a lot of timeout and lock contention problems . Only if the consistency of data is ensured and a large number of concurrency can be accepted , To consider using this level .
版权声明
本文为[cqwoniu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230622032004.html
边栏推荐
- ogldev-读书笔记
- [LNOI2014]LCA——树链剖分——多点LCA深度和问题
- [牛客挑战赛47]C.条件 (bitset加速floyd)
- 6.聚合函数和分组统计
- P2257 YY的GCD(莫比乌斯反演)
- Django使用mysql数据库报错解决
- The difference and application of VR, AR and MR, as well as some implementation principles of AR technology
- Discussion on arrow function of ES6
- NPM installation stepping pit
- 状态同步与帧同步
猜你喜欢

Authorization+Token+JWT

Background management system framework, there is always what you want

反思 | Android 音视频缓存机制的系统性设计
![[Educational Codeforces Round 80] 解题报告](/img/54/2fd298ddce3cd3e28a8fe42b3b8a42.png)
[Educational Codeforces Round 80] 解题报告

Meishe helps Baidu "Duka editing" to make knowledge creation easier

‘npm‘不是内部或外部命令,也不是可运行的程序 或批处理文件

Mysql 数据库从设计上的优化

如何SQL 语句UNION实现当一个表中的一列内容为空时则取另一个表的另一列

Nacos / sentinel gateway current limiting and grouping (code)

Meishe technology launches professional video editing solution for desktop -- Meiying PC version
随机推荐
【TED系列】一个习惯是如何改变我的一生
快速傅里叶变换FFT简明教程
Two threads print odd and even numbers interactively
[牛客挑战赛47]C.条件 (bitset加速floyd)
FSM有限状态机
ESP32学习-GPIO的使用与配置
开发板如何ping通百度
Background management system framework, there is always what you want
安装配置淘宝镜像npm(cnpm)
Mysql隔离级别
Object. Create() principle, object Create() specification, handwritten object create(),Object. Create() usage
数论分块(整除分块)
Pycharm
菜菜的并发编程笔记 |(九)异步IO实现并发爬虫加速
1. View databases and tables
组合数求解与(扩展)卢卡斯定理
手游的热更方案与动态更新策略
(扩展)BSGS与高次同余方程
What is a closure?
学习笔记6-几种深度学习卷积神经网络的总结