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