当前位置:网站首页>2022.6.28-database-1 Isolation level of database

2022.6.28-database-1 Isolation level of database

2022-07-19 02:32:00 HYYyyying

attention!!! Transferred from a Xiu , Personal boredom casually excerpts

Uncommitted read

Changes have taken place in the transaction , Even if it's not submitted , Other things can also be seen , For example, for a number A original 50 It is amended as follows 100, But I haven't submitted the changes , Another transaction sees this change , At this time, the original transaction is rolled back , Now A still 50,, But another thing to see A yes 100. May cause Dirty reading 、 Fantasy reading 、 It can't be read repeatedly .

Submit to read

For a transaction from the beginning until the commit , Any changes made are invisible to other transactions , For example, for a number A Turned out to be 50, Then submit the changes to 100, Another business is at this time A Before submitting the changes , Read the A yes 50, Just finished reading ,A It was modified to 100, At this time, another transaction will perform read discovery A It suddenly became 100 了 ; Can prevent dirty reading , But phantom or unrepeatable reads can still occur .

Repeated reading

It means that the records read multiple times for a record are the same , For example, for a number A The words read have always been A, Read twice before and after A It's consistent ; Can prevent dirty and unrepeatable read , But unreal reading can happen .

Serializable reading

In the case of concurrency , The reading result of serialization is consistent , There is no difference , For example, there will be no dirty reading and unreal reading , This level prevents dirty reads 、 Unrepeatable reading and phantom reading .

MYSQL innoDB The default isolation level supported by the storage engine is repeatable

1、 Dirty reading : Dirty reading is when a transaction is accessing data , And the data has been modified , This modification has not yet been committed to the database , At this time , Another transaction also accesses this data , And then I used this data .

2、 It can't be read repeatedly : Within a transaction , Read the same data multiple times . Before the end of the business , Another transaction also accesses the same data . that , Between two reads in the first transaction , Due to the modification of the second transaction , So the data read by the first transaction twice may be different . This happens that the data read twice in a transaction is different , So it's called unrepeatable reading .

3、 Fantasy reading : A phenomenon that occurs when a transaction is not executed independently , For example, the first transaction modifies the data in a table , This modification involves all data rows in the table . meanwhile , The second transaction also modifies the data in this table , This modification is to insert a new row of data into the table . that , In the future, the user who operates on the first transaction will find out whether there are any modified data rows in the table , It's like an illusion .

原网站

版权声明
本文为[HYYyyying]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/200/202207170008588551.html