zoukankan      html  css  js  c++  java
  • If one session has a shared or exclusive lock on record R in an index, another session cannot insert

    If one session has a shared or exclusive lock on record R in an index, another session cannot insert a new index 
    
    record in the gap immediately before R in the index order. 
    
    如果一个session 有一个共享或者排它锁在记录R上,另外的session 不能插入新的index record 在before R这个区间
    
    
    
    Session 1:
    
    mysql> start transaction;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select * from SmsTest where phoneNo=10 for update;
    +-------+---------+-------------+--------+
    | sn    | phoneNo | channelType | status |
    +-------+---------+-------------+--------+
    |    10 |      10 |           2 |      1 |
    | 45239 |      10 |           1 |      1 |
    | 45252 |      10 |           1 |      1 |
    +-------+---------+-------------+--------+
    3 rows in set (0.01 sec)
    
    
    
    
    Session 2:
    
    Database changed
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(1,1,1);
    Query OK, 1 row affected (0.01 sec)
    
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(2,1,1);
    Query OK, 1 row affected (0.00 sec)
    
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(3,1,1);
    Query OK, 1 row affected (0.01 sec)
    
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(4,1,1);
    Query OK, 1 row affected (0.00 sec)
    
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(5,1,1);
    Query OK, 1 row affected (0.00 sec)
    
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(6,1,1);
    Query OK, 1 row affected (0.00 sec)
    
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(7,1,1);
    Query OK, 1 row affected (0.00 sec)
    
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(8,1,1);
    Query OK, 1 row affected (0.01 sec)
    
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(9,1,1);
    ^[[A
    ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(9,1,1);
    ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(10,1,1); --hang
    
    mysql>  insert into zjzc.SmsTest(PhoneNo,channelType,status)  values(11,1,1);
    Query OK, 1 row affected (0.01 sec)
    

  • 相关阅读:
    期货结算 期货算法公式
    c# websocket 服务端,客户端 兼容低版本IE,支持超长数据传输 附源码
    翻译API translate api 翻译文档api 百度翻译
    asp.net c# 网页 导出excel 多表格 多个sheet
    创建单线程单元 asp.net下使用WebBrowser
    c++ 修改内存
    c++ int to byte
    webservice 第一节 .net SoapHeader验证
    myeclipse maven编译出错
    java用正则表达式获取domain
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350133.html
Copyright © 2011-2022 走看看