标签:
幻读(Phantom Read) 是指当用户读取某一范围的数据行时,B事务在该范围内插入了新行,当用户再读取该范围的数据行时,会发现有新的“幻影”行。InnoDB和Falcon存储引擎通 过多版本并发控制机制解决了幻读问题。
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事务读取了B事务已经提交的新增数据,此时 A 还没有提交,当前提交后,也就看到了
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)
事务B
mysql> insert into test (a,b) values(80,80);
Query OK, 1 row affected (0.00 sec)
事务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)
事务B
mysql> commit;
Query OK, 0 rows affected (0.01 sec)
事务A 此时若不commit,是看不到事务B insert的数据的
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)
标签:
原文地址:http://www.cnblogs.com/taek/p/4748889.html