Four kinds of transaction isolation level

Interview vernacular, the transaction isolation level

Transaction with atomicity, consistency, isolation, durability.

Using Mysql database transaction isolation level instructions:

  mysql support services are commonly used InnoDB engine

  mysql default transaction isolation level repeatable read (REPEATABLE-READ): Use show variables like 'tx_isolation' View

  Note: The following second transaction, in the open, uncommitted state.

  The first: Uncommitted Read (read uncommitted)

      The first transaction did not submit updated data, the second transaction can read, it is read uncommitted.

      The first transaction did not submit updated data is rolled back, the second transaction rollback read data, it is dirty read.

      So read uncommitted, may appear dirty read.

  

  The second: Read Committed (read committed), also known as non-repeatable read

      The first transaction did not submit updated data, the second transaction can not read;

      The first transaction submitted updated data, the second transaction can read; it is read committed.

      The first transaction commits update Xiaoming students aged 12, the second transaction read Xiaoming 12 years old;

      The third transaction commit again to update Xiaoming students aged 14 years old, the second transaction re-read 14-year-old Xiao Ming; this is not repeatable read (reading the data results in the same transaction inconsistent).

      So reading has been submitted, there will be (within the same transaction to read inconsistent data results) non-repeatable read, non-repeatable reads can also cause (inconsistent data results read within the same transaction) phantom reads.

 

  Third: Repeatable read (repeatable read), mysql default transaction isolation level

      The first transaction commits update Xiaoming students aged 12, the second transaction read Xiaoming 12 years old;

      The third transaction commit again to update Xiaoming students aged 14 years old, the second transaction re-read 12-year-old Xiao Ming; this is repeatable read (with a read consistent data within the transaction results).

      The fourth transaction commit insert classmates pony data record, the second transaction read only read about 12-year-old Xiao Ming data, pony students will read the data, this is the phantom reads.

      Therefore, repeatable read, it appears (data reads result in the same transaction inconsistent) phantom read.

 

  Fourth: serialization (serializable)

      Isolation highest level to solve the dirty read, unrepeatable no, phantom read problem.

      Within the same transaction, no matter how many times read, the result set is always the same.

Guess you like

Origin www.cnblogs.com/zwcry/p/12048493.html