All consistent reads within the same transaction read the snapshot established by the first read.
Session 1: Session 2: mysql> show variables like '%tx_isolation%';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| tx_isolation | REPEATABLE-READ |
+---------------+-----------------+
1 row in set (0.00 sec) Session 1: mysql> select * from t100; --看到的记录为291 mysql> update t100 set free = free -quota where sn=10; | 10 | 300 | 1 | 291 | Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> commit;
Query OK, 0 rows affected (0.01 sec) mysql> select * from t100;
+----+------+-------+------+
| sn | id | quota | free |
+----+------+-------+------+
| 1 | 7 | NULL | NULL |
| 2 | 9 | NULL | NULL |
| 3 | 990 | NULL | NULL |
| 4 | 12 | NULL | NULL |
| 5 | 13 | NULL | NULL |
| 6 | 14 | NULL | NULL |
| 7 | 15 | NULL | NULL |
| 8 | 22 | NULL | NULL |
| 9 | 23 | NULL | NULL |
| 10 | 300 | 1 | 291 |
+----+------+-------+------+
10 rows in set (0.00 sec) mysql> update t100 set free = free -quota where sn=10; Session 2看到的仍旧是291
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> commit;
Query OK, 0 rows affected (0.01 sec) mysql> select * from t100;
+----+------+-------+------+
| sn | id | quota | free |
+----+------+-------+------+
| 1 | 7 | NULL | NULL |
| 2 | 9 | NULL | NULL |
| 3 | 990 | NULL | NULL |
| 4 | 12 | NULL | NULL |
| 5 | 13 | NULL | NULL |
| 6 | 14 | NULL | NULL |
| 7 | 15 | NULL | NULL |
| 8 | 22 | NULL | NULL |
| 9 | 23 | NULL | NULL |
| 10 | 300 | 1 | 290 |
+----+------+-------+------+ RR模式下 以第一次读为准 All consistent reads within the same transaction read the snapshot established by the first read. 所有的一致性读 在相同事务读取快照 有第一次读创建
All consistent reads within the same transaction read the snapshot established by the first read.的更多相关文章
- MySQL 5.6 Reference Manual-14.3 InnoDB Transaction Model and Locking
14.3 InnoDB Transaction Model and Locking 14.3.1 InnoDB Lock Modes 14.3.2 InnoDB Record, Gap, and Ne ...
- MySQL 一致性读 深入研究
一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文档:http://dev.mysql.com/doc/refman/5.6/en/innod ...
- MySQL 一致性读 深入研究 digdeep博客学习
http://www.cnblogs.com/digdeep/p/4947694.html 一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文 ...
- Mysql rr和rc隔离
REPEATABLE READ This is the default isolation level for InnoDB. For consistent reads, there is an im ...
- Mysql加锁过程详解(7)-初步理解MySQL的gap锁
Mysql加锁过程详解(1)-基本知识 Mysql加锁过程详解(2)-关于mysql 幻读理解 Mysql加锁过程详解(3)-关于mysql 幻读理解 Mysql加锁过程详解(4)-select fo ...
- MySQL--事务隔离级别RR和RC的异同
在MySQL中,事务隔离级别RC(read commit)和RR(repeatable read)两种事务隔离级别基于多版本并发控制MVCC(multi-version concurrency con ...
- mysql 锁2
官网地址 https://dev.mysql.com/doc/refman/5.5/en/innodb-transaction-isolation-levels.html 这里主要是说事务隔离级别,以 ...
- MySQL Gap Lock问题
四种隔离级别说明 隔离级别 脏读(Dirty Read) 不可重复读(NonRepeatable Read) 幻读(Phantom Read) 未提交读(Read uncommitted) 可能 可能 ...
- MySQL Transaction--RC和RR区别
在MySQL中,事务隔离级别RC(read commit)和RR(repeatable read)两种事务隔离级别基于多版本并发控制MVCC(multi-version concurrency con ...
随机推荐
- mysql入门记录
mysql -h localhost(or ID) -u root -p show databases; create database <数据库名>: drop database < ...
- 12 - 多线程、执行队列、GCD
一.多线程 进程:一个应用程序配套一个进程,进程会加载应用程序的资源,进程是放代码的,一个进程默认是一个线程(主线程),可以有多个线程 线程:执行代码的是线程,一个线程同时只能读取一段代码 栈里的变量 ...
- Mapper XML Files详解
扫扫关注"茶爸爸"微信公众号 坚持最初的执着,从不曾有半点懈怠,为优秀而努力,为证明自己而活. Mapper XML Files The true power of MyBatis ...
- cocos2d-x游戏开发系列教程-坦克大战游戏之敌方坦克AI的编写
在上篇我们完成了子弹和地图碰撞的检测,在这篇我们将完成敌方坦克AI的编写. 具体思路是屏幕中保持有四个敌方坦克,然后坦克随机方向运动,并且子弹消失后1秒发射一次 1.我们新建一个敌方坦克的AI类来控制 ...
- windows api 梳理
PathMatchSpec Function Searches a string using a Microsoft MS-DOS wild card match type. Syntax BOOL ...
- 语法糖(Syntactic sugar)
语法糖(Syntactic sugar),是由Peter J. Landin(和图灵一样的天才人物,是他最先发现了Lambda演算,由此而创立了函数式编程)创造的一个词语,它意指那些没有给计算机语言添 ...
- MySQL存储引擎:InnoDB和MyISAM的差别/优劣评价/评测/性能测试
InnoDB和MyISAM简介 MyISAM:这个是默认类型,它是基于传统的ISAM类型,ISAM是Indexed Sequential Access Method (有索引的 顺序访问方法) 的缩写 ...
- 二维码闪电登录流程详解,附demo(2/2)
上篇文章,我们重点介绍了一下二维码登录的流程,以及每个“角色”要做的事情,下面我们重点分析TV角色所做的工作. TV主要完成二维码图片显示,以及websocket请求.下面重点说一下这两点. 1. B ...
- <转载>网页设计中的F式布局
地址:http://www.uisdc.com/understanding-the-f-layout-in-web-design 网页设计中的F式布局 今天我们来重点介绍网页设计中的F式布局.传统的布 ...
- 解决Xcode 7编译错误:does not contain bitcode
连接地址:http://jingyan.baidu.com/article/8065f87f96cf462331249801.html 好不容易更新到Xcode 7.0.1,重新编译代码,报错: do ...