zoukankan      html  css  js  c++  java
  • 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.
    
    所有的一致性读 在相同事务读取快照 有第一次读创建
    

  • 相关阅读:
    基于连通性状态压缩的动态规划问题
    2005年IT行业趋势Top10
    企业应用之性能实时度量系统演变
    云计算参考架构几例
    在CentOS上构建.net自动化编译环境
    Asp.net SignalR 实现服务端消息推送到Web端
    餐饮行业解决方案之客户分析流程
    餐饮行业解决方案之采购战略制定与实施流程
    餐饮行业解决方案之业务设计流程
    零售连锁专卖信息化解决方案简介之三
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199842.html
Copyright © 2011-2022 走看看