Transaction (transaction), there are four properties: atomicity, consistency, isolation, durability, in which the most important is the consistency of atomicity, isolation, durability guaranteed.
Isolation is divided into:
- Uncommitted Read (RU)
- Read Committed (RC)
- Repeatable Read (RR)
- Serialization (Serializable)
Each level will solve different problems, usually: dirty reads, non-repeatable reads and phantom reads
Dirty read | Non-repeatable read | Magic Reading | |
RU | √ | √ | √ |
RC | × | √ | √ |
RR | × | × | × |
Serializble | × | × | × |
In the MySql, RR level will not lead to phantom read, such as when using the default select, MySQL using MVCC mechanism to ensure that no phantom read
Atomicity: a transaction is complete the operation, the steps of the transaction are not subdivided, it is either executed or not executed
Consistency: When the transaction is completed, the data must be in a consistent state
Isolation: All modifications transaction data is not disturbed by other transaction is independent, it does not rely on or affect other transactions
Durability: After the completion of the transaction, changes to the database are permanently stored, the transaction log to maintain durability of transactions