当前位置:网站首页>Database isolation level
Database isolation level
2022-07-06 06:15:00 【Snow peak expensive】
According to the problems caused by concurrency , Modify the isolation level to avoid .
One 、 Update missing :
background : Isolation level :READ-UNCOMMITED
Due to withdrawal transaction rollback , As a result, the modified data of the deposit transaction is overwritten . An update was lost .
solve : because InnoDB Will lock us , So this situation will not happen today .
Two 、 Dirty reading
background : Isolation level :READ-UNCOMMITTED
Due to reading the data of uncommitted transactions , Cause exception .
Someone has 1000 element .
I read about the withdrawal transaction 1000.
Withdrawal transaction deduction 100 Yuan Yu 900 element .
I read about the deposit transaction 900 element .
The withdrawal transaction rolled back , Remnant 1000 .
Deposit transactions with read 900+1000, Remnant 1900 element .
The withdrawal was cancelled , Resulting in less deposits 100.
solve : Set isolation level :set session transation isolation level read committed;
Isolation level :READ-COMMITTED
Someone has 1000 element .
I read about the withdrawal transaction 1000.
Withdrawal transaction deduction 100 Yuan Yu 900 element .
I read about the deposit transaction 1000 element .
The withdrawal transaction rolled back , Remnant 1000 .
Deposit transactions with read 1000+1000, Remnant 2000 element .
The withdrawal was cancelled , The correctness of the data is not affected .
3、 ... and 、 It can't be read repeatedly
background : Isolation level :READ-COMMITTED
Business A Read data multiple times , Business B In the transaction A In the process of reading many times, the data is modified and submitted . Cause transaction A The data read each time is different .
Business A I read 1000 element .
Business B I read 1000 element . Add 1000, Remnant 2000.
Business A I read again 1000 element .( Because the isolation level is READ-COMMITTED)
Business B Submit .
Business A I read 2000. As a result, the data read before and after are different .
solve : Set isolation level :set session transation isolation level repeatable read;
Isolation level :REPEATABLE-READ
Business A I read 1000 element .
Business B I read 1000 element . Add 1000, Remnant 2000.
Business A I read again 1000 element .( Because the isolation level is READ-COMMITTED)
Business B Submit .
Business A I read 1000. The data read before and after are the same .
namely : The current transaction is submitted regardless of how other transactions are modified , I still use my own data .
Four 、 Fantasy reading
background : Isolation level :REPEATABLE-READ
Business A Currently, we have found 4 Data .
Business B Insert \ Delete A piece of data , Submit .
Business A Update data , Found an update 5 strip \3 strip . There seems to be an illusion .
solve : Set isolation level :set session transation isolation level serializable;
Isolation level :SERIALIZABLE
namely : Serial . But it will affect the concurrency efficiency .
summary
边栏推荐
- Win10 cannot operate (delete, cut) files
- Commodity price visualization
- Overview of three core areas of Mathematics: geometry
- PAT(乙级)2022年夏季考试
- LeetCode 731. 我的日程安排表 II
- 调用链监控Zipkin、sleuth搭建与整合
- [eolink] PC client installation
- Nodejs realizes the third-party login of Weibo
- Gtest之TEST宏的用法
- Aike AI frontier promotion (2.13)
猜你喜欢
PAT(乙级)2022年夏季考试
Significance of unit testing
Usage of test macro of GTEST
Nodejs realizes the third-party login of Weibo
D - How Many Answers Are Wrong
[wechat applet] build a development tool environment
Buuctf-[gxyctf2019] no dolls (xiaoyute detailed explanation)
黑猫带你学UFS协议第4篇:UFS协议栈详解
LeetCode 739. 每日温度
G - Supermarket
随机推荐
LeetCode 729. 我的日程安排表 I
[C language] qsort function
在线问题与离线问题
selenium源码通读·9 |DesiredCapabilities类分析
假设检验学习笔记
【API接口工具】postman-界面使用介绍
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
JMeter做接口测试,如何提取登录Cookie
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
异常检测方法总结
Sqlmap tutorial (III) practical skills II
误差的基本知识
HCIA review
Isam2 operation process
【Postman】测试(Tests)脚本编写和断言详解
数据库隔离级别
浅谈专项测试之弱网络测试
调用链监控Zipkin、sleuth搭建与整合
Accélération de la lecture vidéo de l'entreprise
【C语言】字符串左旋