MySQL Phantom read

Source: Internet
Author: User

Phantom Read (Phantom read) is when a user reads a range of data rows, the B transaction inserts a new row within that range, and when the user reads the data row of that range, a new phantom row is found. The InnoDB and Falcon storage engines solve the Phantom reading problem through multiple versioning concurrency control mechanisms.

http://bbs.csdn.net/topics/360050896

http://narcissusoyf.iteye.com/blog/1637309

http://hudeyong926.iteye.com/blog/1490687

Http://imysql.cn/2008_07_10_innodb_tx_isolation_and_lock_mode

Http://www.cnblogs.com/zhaoyl/p/4121010.html

A transaction reads the new data that has been submitted by the B transaction, at which point A has not yet been committed, and after the current commit, you will see

A transaction

Mysql> select * from test;
+----+----+
| A | B |
+----+----+
| 14 | 14 |
| 16 | 16 |
| 10 | 20 |
| 31 | 31 |
| 33 | 33 |
| 38 | 38 |
| 50 | 60 |
| 70 | 70 |
+----+----+
8 rows in Set (0.00 sec)

Transaction b

mysql> INSERT INTO Test (A, B) values (80,80);
Query OK, 1 row Affected (0.00 sec)

Transaction A

Mysql> select * from test;
+----+----+
| A | B |
+----+----+
| 14 | 14 |
| 16 | 16 |
| 10 | 20 |
| 31 | 31 |
| 33 | 33 |
| 38 | 38 |
| 50 | 60 |
| 70 | 70 |
+----+----+
8 rows in Set (0.00 sec)

Transaction b

Mysql> commit;
Query OK, 0 rows affected (0.01 sec)

Transaction a does not see the data for the insert of transaction B if it is not a commit at this time

Mysql> select * from test;
+----+----+
| A | B |
+----+----+
| 14 | 14 |
| 16 | 16 |
| 10 | 20 |
| 31 | 31 |
| 33 | 33 |
| 38 | 38 |
| 50 | 60 |
| 70 | 70 |
+----+----+
8 rows in Set (0.00 sec)

Commit

Mysql> select * from test;
+----+----+
| A | B |
+----+----+
| 14 | 14 |
| 16 | 16 |
| 10 | 20 |
| 31 | 31 |
| 33 | 33 |
| 38 | 38 |
| 50 | 60 |
| 70 | 70 |
| 80 | 80 |
+----+----+
9 Rows in Set (0.00 sec)

MySQL 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.