Database - transaction isolation level

READ-UNCOMMITED (read uncommitted)

A transaction can read uncommitted data transaction B, and will have a dirty read, this transaction isolation level occurs dirty reads, non-repeatable read, phantom read .

READ-COMMITED (Read Committed)

The transaction can only see the data already submitted before the operation and then submit the transaction to other transactions are not visible.

This level may appear non-repeatable read Transaction A first read c, but before submitting the transaction A Transaction B modifies c and submit the transaction A read on the original and not the same, repeatable read results are not the same , may also occur phantom reads .

REPEATABLE READ (repeatable read)

The same transaction multiple times to read the same record result is the same, the MySQL default isolation level.

Possible phantom read , such as Transaction A reads a record within a range of transaction B and then insert a new record in this range, then again when A reading appeared magic line.

In MySQL's InnoDB and XtraDB in solving the phantom reads by MVCC.

SERIALIZABEL (serializable)

Force transaction serial execution, to avoid all the problems earlier, could lead to a lot of timeouts and lock contention problems.

MVCC (multi-version concurrency control)

InnoDB is saved after each line by two hidden columns to achieve, it was preserved to create a time line and expiration date , save the system from time to time version, not the beginning of a new transaction will increment the version number.

In repeatable read MVCC:

SELECT:

1) InnoDB only to find the system version number is earlier than the current transaction version of the row, which is less than or equal to line transaction system version number, so you can ensure a transaction before the transaction reads the start line already exists, either insert their own affairs or modified.

2) delete the version number of the line is either undefined or greater than the version number of transactions, to ensure that large transaction read line before the start of the transaction have not been deleted.

INSERT:

1) InnoDB bit of the newly inserted row to save the current system version number as the row version.

DELETE:

1) Save the current version number as the cancellation mark

UPDATE:

1) InnoDB to insert a new record line, save the current system version number for the new line version, save for deletion identifies the current version number of the original line.

 

MVCC only submitted work in the next two isolation level repeatable read and read.

Guess you like

Origin www.cnblogs.com/KuroNJQ/p/11331021.html