当前位置:网站首页>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 installing socket5 proxy server
- Sword finger offer04 Search in two-dimensional array [medium]
- Apache Mina Development Manual
- Sword finger offer06 Print linked list from end to end
- Enter the length of three sides of the triangle through the user, and calculate the area of the triangle, where the length is a real number
- Social community forum app ultra-high appearance UI interface
- Sword finger offer10- I. Fibonacci sequence
- 电压环对 PFC 系统性能影响分析
- Sword finger offer05 Replace spaces
- Node.js: express + MySQL的使用
猜你喜欢
![[download attached] password acquisition tool lazagne installation and use](/img/21/eccf87ad9946d4177b600d96e17322.png)
[download attached] password acquisition tool lazagne installation and use

How to get user location in wechat applet?

Integer case study of packaging

Analysis of a music player Login Protocol

What is more elegant for flutter to log out and confirm again?

Record your vulnhub breakthrough record

最新版盲盒商城thinkphp+uniapp

Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
![Sword finger offer03 Repeated numbers in the array [simple]](/img/cf/c1ad2f2a45560b674b5b8c11fed244.png)
Sword finger offer03 Repeated numbers in the array [simple]

Swift bit operation exercise
随机推荐
4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
Everything comes to him who waits
【习题七】【数据库原理】
01_ Using the concurrent tool class library, is thread safety safe
GCN thinking - word2vec directly calculates text classification
Use bloc to build a page instance of shutter
Detailed explanation of the most complete constraintlayout in history
Do you feel like you've learned something and forgotten it?
自抗扰控制器七-二阶 LADRC-PLL 结构设计
初入职场,如何快速脱颖而出?
ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
十條職場規則
剑指Offer05. 替换空格
Dix règles de travail
Bert running error: attributeerror: module'tensorflow contrib. tpu' has no attribute 'InputPipelineConfig'
基于Linu开发的项目视频
Lambda expression
The future of cloud computing cloud native
十条职场规则
Sword finger offer05 Replace spaces