Reflections from dirty data, non-repeatable read, phantom read

   1 premise: transaction concurrency

   2. Dirty read: A read data D, modify the data D, B reads D, A rollback.

      Solution: A plus a write before the read lock until the end of the transaction before the release, plus read lock before reading each transaction, to prevent being modified, the corresponding database isolation level 2 (default level)

   3. Non-repeatable read: because the read lock acquisitions, and continued until the end of the transaction was not released, there may be half-way there are other transactions acquire write lock, resulting in a transaction reads the same data inconsistencies twice.

     Solution: Add a read lock, end of the transaction until the end, and dirty reads like a lock that the read data.

  4. Magic Reading: A reading data D, B insert data D1, D1 can be read out with the same sql A, so A second read out when more than Dl ..

    Solution: range locks, table locks is actually completely serial.

 In fact, non-repeatable read and phantom read in some cases can be received, the business needs to look at

Published 133 original articles · won praise 8 · views 30000 +

Guess you like

Origin blog.csdn.net/fbher/article/details/100179219