The four isolation levels mysql four characteristics of the transaction and the transaction

First, the four characteristics of the transaction

1, atomicity (Atomicity)

Atomicity refers to all operations in the transaction included either all succeed, or all fail rolled back, the operator of the transaction if successful, it must be fully applied to the database if the operation fails it can not have any impact on the database.

2. Consistency (Consistency)

Consistency means that the transaction must transform the database from one consistent state to another consistent state, that is to say before and after a transaction execution and implementation must be in a consistent state.

3, isolation (Isolation)

Isolation when a plurality of users concurrent access to the database, such as when operating simultaneously with a table, a database for each user transaction open, operation not being disturbed by other transactions, for isolation between a plurality of concurrent transactions.

4, persistent (Durability)

Persistence means that once a transaction is committed, then changes to the data in the database is permanent.

 

Two , concurrency issues affairs

1, dirty reads : A read transaction to transaction B has been modified but not yet submitted data, but, if B transaction rollback, the transaction A dirty read is data. Does not meet the consistency.

2, non-repeatable read : A transaction reads the same data multiple times, transaction transaction A B during read many times, the data has been modified and submitted, resulting in multiple transaction A

When reading the same data, the results are inconsistent. Does not comply with isolation.

3, phantom read : Transaction A Transaction B reads the new data submitted or deleted. Does not comply with isolation.

Note: non-repeatable reads and phantom reads are easily confused, non-repeatable read focused on the modification , phantom reads focused on added or deleted.

 

Third, the transaction isolation level

Isolation Levels Dirty read Non-repeatable read Magic Reading
Uncommitted Read (Read uncommitted) No No No
Read Committed (Read committed) Yes No No
Repeatable read (Repeatable the Read) InnoDB the default level Yes Yes No
Serialization (the Serializable) Yes Yes Yes
############################################ ####### ######### ######

                                                                                                                                     Yes: to solve No: Unresolved

 

 

Published 48 original articles · won praise 1 · views 2835

Guess you like

Origin blog.csdn.net/Forest24/article/details/90272519