MySQL features and isolation level and concurrency issues

 
Four characteristics of ACID:
         First, atomicity, which means that all operations involved in a transaction either succeed or fail and roll back. Operational transactions that fail to roll back will not have any impact on things.
         Second, consistency. Consistency means that the transaction must transform the database from one consistency state to another consistency state, that is, a transaction must be in a consistent state before and after execution. How does the database status change? Every data change will cause the state of the database to migrate.
         Third, isolation. Isolation means that when multiple users access a database concurrently, such as accessing a table at the same time, transactions opened by each user of the database cannot be interfered by operations performed by other firms. Between multiple concurrent transactions , Should be isolated from each other.
         Fourth, persistence. Persistence refers to the operation of a transaction. Once submitted, the changes to the data in the database are permanent. Even if the database fails, the changes completed by the submitted transaction cannot be lost.
 
Four isolation levels:
 
         Read submitted
         Read uncommitted
         Repeatable
         Sequential reading
 
Problems caused by concurrency:
        
         Dirty read:
         After the first process started the transaction, a certain piece of data in the database was modified, but it was not submitted. At this time, the second process also opened the transaction to read and submit the modified data of the first process, but the first process suddenly rolled back to the last Before modification, the data obtained by process two is wrong
        Non-repeatable reading:
        Process one starts a transaction to read a piece of data in the database for the first time, but does not submit it. At the same time, process two starts a transaction to modify the same piece of data in the database and submit it. At this time, process one performs data on the database again Read twice, then you will find that the results of the process read once and twice are inconsistent
        Phantom reading:
        Process one opens a transaction to modify the corresponding value of the original field of a certain block of data in the database for the first time, but does not submit it. At the same time, process two opens a transaction to add or delete fields in the same data block and submit it. When the process is submitted, it will be found that there are unmodified fields or the original field values ​​are gone.
 

Guess you like

Origin blog.csdn.net/weixin_43562937/article/details/106493876