当前位置:网站首页>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
边栏推荐
- Embedded point test of app
- [leetcode] day96 - the first unique character & ransom letter & letter ectopic word
- [course notes] Compilation Principle
- Commodity price visualization
- 一文揭开,测试外包公司的真 相
- Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
- Leaflet map
- LeetCode 732. 我的日程安排表 III
- leaflet 地图
- 全链路压测:构建三大模型
猜你喜欢
ESP32 ESP-IDF看门狗TWDT
(5) Explanation of yolo-v3 core source code (3)
MySQL之基础知识
About PHP startup, mongodb cannot find the specified module
Manhattan distance and Manhattan rectangle - print back font matrix
进程和线程的理解
Embedded point test of app
10m25dcf484c8g (FPGA) amy-6m-0002 BGA GPS module
VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator
【无App Push 通用测试方案
随机推荐
Digital triangle model acwing 1015 Picking flowers
GTSAM中ISAM2和IncrementalFixedLagSmoother说明
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
【Postman】动态变量(也称Mock函数)
[C language] qsort function
曼哈顿距离与曼哈顿矩形-打印回字型矩阵
[course notes] Compilation Principle
Pat (Grade B) 2022 summer exam
Interface test: what are the components of the URL in fiddler
Web界面元素的测试
【Postman】Collections-运行配置之导入数据文件
Linux regularly backs up MySQL database
Coordinatorlayout+nestedscrollview+recyclerview pull up the bottom display is incomplete
[postman] collections configuration running process
【Postman】测试(Tests)脚本编写和断言详解
Caused by:org. gradle. api. internal. plugins . PluginApplicationException: Failed to apply plugin
Cannot create PoolableConnectionFactory (Could not create connection to database server. 错误
D - How Many Answers Are Wrong
Configuring OSPF GR features for Huawei devices
Nodejs realizes the third-party login of Weibo