Database stolen, non-repeatable read, Phantom read

Source: Internet
Author: User

These are issues that arise from transaction concurrency.

There are five levels of transaction isolation:
Transaction_none does not use transactions.
transaction_read_uncommitted allow dirty reads.
Transaction_read_committed prevents dirty reads, the most common isolation level, and is the default isolation level for most databases
Transaction_repeatable_read can prevent dirty reads and non-repeatable reads,
Transaction_serializable can prevent dirty reads, non-repeatable reads, and Phantom reads (transactional serialization) to reduce database efficiency

Basic concepts

Stolen dirty read:

  One transaction reads data that is not committed by another transaction

Avoidable scenarios: Read Committed reads commits, a transaction is committed and then read.

The default level for most databases is read committed, such as SQL Server, Oracle.

Non-repeatable READ:

  In the same transaction, read the same data two times to get different content

Avoidable scenario: (That is, the implementation can be read repeatedly), the database transaction isolation level repeatable read. One transaction A is in progress, and another transaction B is not allowed to manipulate the data involved in this transaction.

The default isolation level for MySQL is repeatable read.

Phantom read:

  The same transaction, read two times with the same operation, resulting in a different number of records

Phantom reading is a phenomenon that occurs when a transaction is not executed independently, such as when the first transaction modifies data in a table that involves all rows of data in the table. At the same time, the second transaction also modifies the data in this table, which is a change to a table

Inserts a new row of data into the Then the user who will be working on the first transaction in the future finds that there are no modified rows of data in the table, as if the illusion had occurred.

Scenarios that can be avoided:

Serializable: is the highest transaction isolation level, at the expense of the highest cost, performance is very low, generally rarely used, at this level, the transaction order execution, not only can avoid dirty read, non-repeatable read, but also avoid phantom read.

" Reference link "

http://blog.csdn.net/jiesa/article/details/51317164

http://blog.csdn.net/gaoshan_820822/article/details/4582561

Database stolen, non-repeatable read, Phantom read

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.