MySQL transaction isolation level

1. What is a thing

    A complete program execution unit (UNIT) to access and possibly follow new databases

2. Things must meet the ACID characteristics:
A, atomic, atomic, either all commits, or all fail, not part of the success, part of the failure.
C, consistent, consistency, after the start and end of things, the data consistency constraints are not destroyed
I, isolation, isolation, concurrent things do not affect each other, do not interfere with each other.
D, durability, persistence, the updates made to the database by things that have been committed must be permanently saved. Even in the event of a crash, it cannot be rolled back or data lost.

3. Problems in things:

Drity Read: A transaction has updated a piece of data, and another transaction has read the same piece of data at this time. For some reason, the previous RollBack operation is performed, and the data read by the latter transaction is would be incorrect.

         Non-repeatable read (Non-repeatable read): The data is inconsistent between two queries of a transaction, which may be the original data updated by a transaction inserted between the two queries.

         Phantom Read: In the two queries of a transaction, the number of data is inconsistent. For example, one transaction queried several columns of (Row) data, while another transaction inserted new columns of data at this time. In the next query, the transaction will find several columns of data that it did not have before.

       

         In MySQL, these four isolation levels are implemented, which may cause problems as follows:


4. The isolation level of four things:
READ UNCOMMITED RU: read uncommitted, in one thing, you can read the changes submitted by other things.
READ COMMITTED, RC: Read committed, in one thing, you can read changes that have been committed by other things.
REPEATABLE READ, RR repeatable read: In a transaction, until the end of the transaction, the data seen at the beginning can be read repeatedly without changing. This level can ensure the consistency of the transaction.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326349641&siteId=291194637