Always forget the scene: MySQL InnoDB four transaction levels with dirty read, no repetition, Phantom read

Source: Internet
Author: User
Tags repetition

MySQL INNODB Transaction ISOLATION level dirty read, repeatable read, Phantom read

The level of isolation for MySQL InnoDB transactions is level four, which is "repeatable read" by default (Repeatable Read).

· READ UNCOMMITTED (readuncommitted). Another transaction modifies the data but has not yet committed, and select in this transaction reads the uncommitted data (dirty read).

· Submit Read (readcommitted). This transaction reads the most up-to-date data (after other transactions have been committed). The problem is that in the same transaction, two times the same select will read different results (do not repeat).

· Repeatable Read (RepeatableRead). In the same transaction, the result of select is the state of the point in time at which the transaction started, so the same select operation will read the same result. However, there is a phantom reading phenomenon (explained later).

· Serialization (SERIALIZABLE). A read operation implicitly acquires a shared lock, which guarantees mutual exclusion between different transactions.

Four levels are gradually enhanced, and each level solves a problem.

· Dirty read, the most easy to understand. Another transaction modifies the data but has not yet committed, and select in this transaction reads the uncommitted data.

· Do not repeat the repetition. After the dirty read is resolved, the same transaction is executed, another transaction commits the new data, so the result of the data read two times in this transaction will be inconsistent.

· Phantom read. solves the non-repetition, guarantees the same transaction, the result of the query is the state (consistency) at the beginning of the transaction. However, if another transaction commits new data at the same time, when the transaction is updated, the new data is "surprisingly" discovered, as if the previously read data were "ghost" hallucinations.

Always forget the scene: MySQL InnoDB four transaction levels with dirty read, no repetition, Phantom read

Related Article

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.