MySQL transaction isolation level solves concurrency issues, mysql transactions

Source: Internet
Author: User

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"

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.