Four transaction isolation level

Database isolation level operations

  • Setting the isolation level: SET TX_ISOLATION = 'the READ-UNCOMMITTED'
  • View isolation levels: the SELECT @@ TX_ISOLATION

A, Read Uncommitted - read uncommitted content

  • A transaction can view uncommitted content
  • Problems often produce dirty read (dirty read: to read the contents of other uncommitted transactions (executed))
    opened on the same data tables A, B two transaction (A, B cross transaction) Start Transaction
    A transaction only query the contents of the data table , B additions and deletions to make the transaction, but not the operation commit (submitted)
    a query to the transaction can still change the data in the table (the query to the content uncommitted - dirty reads)

Two, Read Committed - read submissions

  • A transaction can only see content you have submitted
  • Problems often produce non-repeatable read (non-repeatable reads: select statement to perform the same transaction in the same different results)
    for opening the same data table A, B two transaction (A, B cross transaction) Start Transaction
    A transaction data inquiry only contents of the table, B additions and deletions to make the transaction, but not the operation commit (submitted)
    a transaction is less than the data change query table
    B transaction commit
    data change (a a query found in two, different results - no repeatable read)

Three, Repeatable Read - can be re-read

  • The results obtained when the same data is read multiple concurrent instances of the same transaction
  • MySQL's default transaction isolation level
  • Problems often produce phantom read (phantom reads: multiple different results (phantom line) reading)
    open on the same data tables A, B two transaction (A, B cross transaction) Start Transaction
    A transaction only query the contents of the data table , B additions and deletions to make the transaction, but not the operation commit (submitted)
    a transaction is less than the data change query table
    B transaction commit
    a query data transaction can not change the contents of table
    a, as
    a may query the data in table change

Four, Serializable - serialization

  • Highest level of isolation
  • Plus a shared lock to the transaction, while only one transaction operations, to solve the problem of phantom read
  • Will lead to a lot of timeouts and lock contention issues
    open A transaction
    can not add or delete the operation of the open transaction B

Guess you like

Origin www.cnblogs.com/QX-Tang/p/11516567.html