MySQL Transaction ISOLATION LEVEL

Source: Internet
Author: User

Read-uncommitted (read not submitted)
Testing process:
1, a set read-uncommitted, start transaction
2, b Execute Start transaction, modify a record,
3, a query record, got the correct record
4, b rollback.
Problem: A reads a record of B without committing, that is, dirty reading.

Read-committed (Read Committed)

Testing process:
1, a set read-committed, start transaction
2, b Execute Start transaction, modify a record, query record, record has been modified successfully
3, a query records, the results are still old records
4, B commit the transaction
5, a again query records, the result is a new record.
Problem: The problem of dirty reads is resolved, but a new problem occurs, a in a transaction, the record of two reads is inconsistent, that is, non-repeatable read.

Repeatable-read (repeatable reading)
Testing process:
1, a set Repeatable-read, start transaction, query record, the result is the old record
2, b Execute Start transaction, modify a record, query record, record has been modified successfully
3, a query records, the results are still old records
4, B commit the transaction
5, a again query records, the results are still old records.
Problem: Can read repeatedly, a during a transaction, even if B modifies the data, and Commit,a reads the old data.
Note: There may be a new problem, a in the transaction process, B adds a record, and commits, resulting in a two reads inconsistent, there will be one more record, that is, Phantom read. This is only possible, depending on the implementation of the database. The repeatable-read implementation of MySQL does not cause phantom reads.

Serializable (Serializable)
Testing process:
1, a set serializable, start transaction, query record, the result is the old record
2, B to execute start transaction, modify a record, B card here, to wait for a to complete before the line.
3, a query records, the result is the old record, a submitted.
4, B of the modification of the operation will continue.
Note: B During the wait process, a lock timeout occurs. In this case, there is a performance problem because one comes.

MySQL Transaction ISOLATION LEVEL

Related Article

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.