MySQL transaction isolation level to solve concurrency problems

MySQL transaction isolation level

1. Dirty read: money making tool, a window or two threads are calling the database transfer table, not submitted after the transfer, the other party to see arrival, rollback, no actual money transfer.

Demonstration of:

mysql default transaction isolation level is repeatable-read higher than Oracle, because mysql itself weak

Use select @@ tx_isolation; view

use

Adjusted to the lowest level

Use start transaction; open transaction rollback; Rollback

2. Non-repeatable read: Transaction A reads the same data multiple times, in the course of the transaction A transaction B read many times, the data were updated and submitted, resulting in a transaction A reads the same data multiple times, the results are inconsistent.

3.  In the client A and the calculation of the table of money, and the present three data values should be 300 + 16000 + 2400 = 18700, the calculated, actually becomes 19300 because the operator 600 of the client B go

, From the customer's point of view, the customer can not see the client B, it will think it is pie in the world, more than 600, this is magic reading, standing on the perspective of developers, data consistency and not damage. However, in the application, it is not desirable, it is necessary to take the transaction isolation level "serialized"

Transfer: https: //www.cnblogs.com/qingyundian/p/8613637.html

Guess you like

Origin www.cnblogs.com/jokmangood/p/11705972.html