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.的更多相关文章

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

  2. MySQL 一致性读 深入研究

    一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文档:http://dev.mysql.com/doc/refman/5.6/en/innod ...

  3. MySQL 一致性读 深入研究 digdeep博客学习

    http://www.cnblogs.com/digdeep/p/4947694.html 一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文 ...

  4. Mysql rr和rc隔离

    REPEATABLE READ This is the default isolation level for InnoDB. For consistent reads, there is an im ...

  5. Mysql加锁过程详解(7)-初步理解MySQL的gap锁

    Mysql加锁过程详解(1)-基本知识 Mysql加锁过程详解(2)-关于mysql 幻读理解 Mysql加锁过程详解(3)-关于mysql 幻读理解 Mysql加锁过程详解(4)-select fo ...

  6. MySQL--事务隔离级别RR和RC的异同

    在MySQL中,事务隔离级别RC(read commit)和RR(repeatable read)两种事务隔离级别基于多版本并发控制MVCC(multi-version concurrency con ...

  7. mysql 锁2

    官网地址 https://dev.mysql.com/doc/refman/5.5/en/innodb-transaction-isolation-levels.html 这里主要是说事务隔离级别,以 ...

  8. MySQL Gap Lock问题

    四种隔离级别说明 隔离级别 脏读(Dirty Read) 不可重复读(NonRepeatable Read) 幻读(Phantom Read) 未提交读(Read uncommitted) 可能 可能 ...

  9. MySQL Transaction--RC和RR区别

    在MySQL中,事务隔离级别RC(read commit)和RR(repeatable read)两种事务隔离级别基于多版本并发控制MVCC(multi-version concurrency con ...

随机推荐

  1. nginx提示:500 Internal Server Error错误的解决方法

    现在越来越多的站点开始用 Nginx ,("engine x") 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx 是由 ...

  2. 网站实战 从效果图开始CSS+DIV 布局华为网站

    经过我们的前面css的学习,我们已经分模块的掌握的CSS的技术,但是,要是完整的做一个页面,我们还没有接触过,这次呢,小强老师来和大家完整的利用CSS+DIV做一个网站案例,我们来模仿下华为的网站. ...

  3. Android 播放声音

    public static void PlayAlarmRing(Context mContext) { Uri alert = RingtoneManager.getDefaultUri(Ringt ...

  4. JVM调优总结(八)-典型配置举例2

    常见配置汇总 堆设置 -Xms:初始堆大小 -Xmx:最大堆大小 -XX:NewSize=n:设置年轻代大小 -XX:NewRatio=n:设置年轻代和年老代的比值.如:为3,表示年轻代与年老代比值为 ...

  5. solr4.x设置默认查询字段

    1.如果需要同时在title和content中进行查询,可以添加如下字段: <field name="title_content" type="textComple ...

  6. haproxy /admin跳转 不会在接口上再次加上admin

    http://www.xx.com/admin/api/menu [root@wx03 mojo]# cat test.pl use Mojolicious::Lite; use JSON qw/en ...

  7. 基于visual Studio2013解决算法导论之008快速排序算法

     题目 快速排序 解决代码及点评 #include <stdio.h> #include <stdlib.h> #include <malloc.h> #in ...

  8. 使用代码辅助生成工具CodeSmith -- 生成NHibernate的映射文件

    首先下载CodeSmith工具:在百度云中,在CodeSmith文件夹中. 安装,使用激活工具激活. 然后下载NHibernate模板,也是在百度云中,在CodeSmith文件夹中. 之后直接点击NH ...

  9. php 中 return exit break contiue 详解

    return.break和contiue是语言结构,就如同if语句之类的,但是exit却是个函数. 1.exit函数 作用:Output a message and terminate the cur ...

  10. php 抓取天气情况 www.weather.com.cn

    <?php print_r(getweather(101120501)); /** * Server 天气情况获取函数 * @param unknown $city */ function ge ...