MySQL transaction isolation level solves concurrency issues, mysql transactions
MySQL transaction isolation level
1. Dirty reading: the method of money fraud. Two windows or threads call the database transfer table respectively, but the table is not submitted after the transfer. After the other party sees the account, it rollback and the actual money is not transferred.
Demo method:
The default transaction isolation level of mysql is repeatable-read, which is higher than that of Oracle, because mysql itself is weak.
Use select @ tx_isolation; To View
Use
Adjusted to the lowest level
Use start transaction; Enable transaction rollback; rollback
2. non-repeated read: Transaction A reads the same data multiple times, and transaction B updates and submits the data while transaction A reads the data multiple times, as A result, transaction A reads the same data multiple times and the results are inconsistent.
3. In the sum of money in Client A's calculation table, the three data values and the sum are 300 + 16000 + 2400 = 18700. After calculation, the sum is actually 19300, this is because the 600 of client B is included.
From the customer's point of view, the customer cannot see client B. It will think that it is a pie in the world, and there are more than 600 RMB. This is phantom reading. From the developer's point of view, data Consistency is not broken. However, in applications, it is not advisable to adopt the transaction isolation level "serialize"