当前位置:网站首页>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 .
边栏推荐
- 【习题五】【数据库原理】
- ORM use of node -serialize
- ImportError: No module named examples. tutorials. mnist
- OpenStack节点地址改变
- Ali & ant self developed IDE
- Idea packages the web project into a war package and deploys it to the server to run
- Bert running error: attributeerror: module'tensorflow contrib. tpu' has no attribute 'InputPipelineConfig'
- 【判断题】【简答题】【数据库原理】
- 【習題七】【數據庫原理】
- JVM memory model
猜你喜欢
Sword finger offer05 Replace spaces
Differences between initial, inherit, unset, revert and all
Sword finger offer09 Implementing queues with two stacks
Application of ncnn neural network computing framework in orange school orangepi 3 lts development board
initial、inherit、unset、revert和all的区别
Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
Glide question you cannot start a load for a destroyed activity
剑指Offer06. 从尾到头打印链表
Cloud Computing future - native Cloud
Analysis of a music player Login Protocol
随机推荐
Swift return type is a function of function
01_ Using the concurrent tool class library, is thread safety safe
Xctf mobile--app3 problem solving
Nodejs+Express+MySQL实现登陆功能(含验证码)
【习题五】【数据库原理】
Simple use and precautions of kotlin's array array and set list
The difference between lambda and anonymous inner class
Approve iPad, which wants to use your icloud account
Oh my Zsh + TMUX installation
Powerful avatar making artifact wechat applet
[download attached] password acquisition tool lazagne installation and use
Harmonic current detection based on synchronous coordinate transformation
Xctf mobile--rememberother problem solving
公纵号发送提示信息(用户微服务--消息微服务)
电压环对 PFC 系统性能影响分析
Export the entire Oracle Database
Project video based on Linu development
ORM use of node -serialize
Attack and defense world mobile--ph0en1x-100
Dix règles de travail