当前位置:网站首页>Four problems and isolation level of MySQL concurrency
Four problems and isolation level of MySQL concurrency
2022-07-03 12:50:00 【Mcc_ mingchao】
What are the problems of concurrent transactions
In a typical application , Multiple transactions run concurrently , Often operate the same data to complete their own tasks ( Multiple users operate on the same data ). Concurrency is necessary , But it may cause the following problems .
Dirty reading (Dirty read): When a transaction is accessing data and modifying the data , This modification has not yet been committed to the database , At this time, another transaction also accesses the data , And then I used this data . Because of this Data is data that has not been submitted , So the data read by another transaction is “ Dirty data ”, basis “ Dirty data ” The operation may not be correct .( Read uncommitted data )
Missing changes (Lost to modify): When a transaction reads a data , Another transaction also accesses the data , After modifying the data in the first transaction , The second transaction also modifies the data . In this way, the modification result in the first transaction will be lost , So it's called lost modification . for example : Business 1 Read data from a table A=20, Business 2 Also read A=20, Business 1 modify A=A-1, Business 2 Also modify A=A-1, final result A=19, Business 1 The modification of is lost .
It can't be read repeatedly (Unrepeatableread): Reading the same data multiple times in a transaction . Before the end of the business , Another transaction also accesses the data . that , 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 . This happens when the data read twice in a transaction is different , So it's called unrepeatable reading .( The period of repeated reading is modified, resulting in different data read twice )
Fantasy reading (Phantom read): Unreal reading is similar to nonrepeatable reading . It happens in a transaction (T1) Read a few lines of data , Then another concurrent transaction (T2) When some data is inserted . In the subsequent query , The first thing (T1) There will be more records that don't exist , It's like an illusion , So it's called Unreal reading .( When reading multiple rows of data, the data is inserted by other transactions )
The difference between nonrepeatable reading and unreal reading :
The key point of non repeatable reading is to modify, such as reading a record many times and finding some columns Value is modified , The point of fantasy reading is Add or delete For example, read a record many times and find that the number of records increases or decreases .
What are the transaction isolation levels ?
SQL The standard defines four isolation levels :
READ-UNCOMMITTED( Read uncommitted ): Lowest isolation level , Allow read of uncommitted data changes , Can cause dirty reading 、 Phantom or unrepeatable reading .
READ-COMMITTED( Read committed ): Allow to read data submitted by concurrent transactions , Can prevent dirty reading , But phantom or unrepeatable reads can still occur .
REPEATABLE-READ( Repeatable ): Multiple reads of the same field are consistent , Unless the data is modified by the transaction itself , Can prevent dirty and unrepeatable read , But phantom reading can still happen .
SERIALIZABLE( Serializable ): Highest isolation level , Completely obey ACID Isolation level . All transactions are executed one by one , In this way, there is no interference between transactions , in other words , This level prevents dirty reads 、 Unrepeatable reading and phantom reading .
- MySQL InnoDB The default isolation level supported by the storage engine is REPEATABLE-READ( Can be reread )InnoDB The storage engine uses... By default REPEAaTABLE-READ( Can be reread ) There will be no loss of performance .
边栏推荐
- RedHat5 安装Socket5代理服务器
- Detailed explanation of the most complete constraintlayout in history
- Redhat5 installing socket5 proxy server
- 初入职场,如何快速脱颖而出?
- elastic_ L04_ introduction. md
- 剑指Offer09. 用两个栈实现队列
- Togaf certification self-study classic v2.0
- 剑指Offer03. 数组中重复的数字【简单】
- GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
- 基于同步坐标变换的谐波电流检测
猜你喜欢
What is more elegant for flutter to log out and confirm again?
Solve the problem of VI opening files with ^m at the end
【ManageEngine】IP地址扫描的作用
剑指Offer07. 重建二叉树
记录自己vulnhub闯关记录
Sword finger offer06 Print linked list from end to end
Social community forum app ultra-high appearance UI interface
【数据库原理复习题】
剑指Offer09. 用两个栈实现队列
Xctf mobile--rememberother problem solving
随机推荐
强大的头像制作神器微信小程序
Sqoop1.4.4原生增量导入特性探秘
Tensorflow binary installation & Failure
elastic_ L04_ introduction. md
Xctf mobile--app1 problem solving
【习题五】【数据库原理】
Bert running error: attributeerror: module'tensorflow contrib. tpu' has no attribute 'InputPipelineConfig'
idea将web项目打包成war包并部署到服务器上运行
Method overloading and rewriting
Lambda expression
最新版盲盒商城thinkphp+uniapp
How to stand out quickly when you are new to the workplace?
[problem exploration and solution of one or more filters or listeners failing to start]
Recovery of website address and method of Amazon account login two-step verification failure caused by mobile phone number becoming empty
【判断题】【简答题】【数据库原理】
Project video based on Linu development
Analysis of a music player Login Protocol
Use bloc to build a page instance of shutter
initial、inherit、unset、revert和all的区别
ImportError: No module named examples. tutorials. mnist