1. If one session has a shared or exclusive lock on record R in an index, another session cannot insert a new index
  2.  
  3. record in the gap immediately before R in the index order.
  4.  
  5. 如果一个session 有一个共享或者排它锁在记录R上,另外的session 不能插入新的index record before R这个区间
  6.  
  7. Session 1:
  8.  
  9. mysql> start transaction;
  10. Query OK, 0 rows affected (0.00 sec)
  11.  
  12. mysql> select * from SmsTest where phoneNo=10 for update;
  13. +-------+---------+-------------+--------+
  14. | sn | phoneNo | channelType | status |
  15. +-------+---------+-------------+--------+
  16. | 10 | 10 | 2 | 1 |
  17. | 45239 | 10 | 1 | 1 |
  18. | 45252 | 10 | 1 | 1 |
  19. +-------+---------+-------------+--------+
  20. 3 rows in set (0.01 sec)
  21.  
  22. Session 2:
  23.  
  24. Database changed
  25. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(1,1,1);
  26. Query OK, 1 row affected (0.01 sec)
  27.  
  28. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(2,1,1);
  29. Query OK, 1 row affected (0.00 sec)
  30.  
  31. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(3,1,1);
  32. Query OK, 1 row affected (0.01 sec)
  33.  
  34. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(4,1,1);
  35. Query OK, 1 row affected (0.00 sec)
  36.  
  37. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(5,1,1);
  38. Query OK, 1 row affected (0.00 sec)
  39.  
  40. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(6,1,1);
  41. Query OK, 1 row affected (0.00 sec)
  42.  
  43. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(7,1,1);
  44. Query OK, 1 row affected (0.00 sec)
  45.  
  46. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(8,1,1);
  47. Query OK, 1 row affected (0.01 sec)
  48.  
  49. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(9,1,1);
  50. ^[[A
  51. ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
  52. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(9,1,1);
  53. ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
  54. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(10,1,1); --hang
  55.  
  56. mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(11,1,1);
  57. Query OK, 1 row affected (0.01 sec)

If one session has a shared or exclusive lock on record R in an index, another session cannot insert的更多相关文章

  1. Shared and Exclusive Locks 共享和排它锁

    14.5 InnoDB Locking and Transaction Model InnoDB 锁和事务模型 14.5.1 InnoDB Locking 14.5.2 InnoDB Transact ...

  2. MySQL Shared and Exclusive Locks

    官方文档 InnoDB implements standard row-level locking where there are two types of locks, shared (S) loc ...

  3. 启动weblogic的错误:Could not obtain an exclusive lock to the embedded LDAP data files directory

    http://hi.baidu.com/kaisep/item/0e4bf6ee5da001d1ea34c986 源地址 启动weblogic的错误:Could not obtain an exclu ...

  4. java:Session(概述,三层架构实例(实现接口封装JDBC),Session实现简单购物车实例)

    1.Session概述: Session:在计算机中,尤其是在网络应用中,称为“会话控制”.Session 对象存储特定用户会话所需的属性及配置信息.这样,当用户在应用程序的 Web 页之间跳转时,存 ...

  5. 深入理解Java并发框架AQS系列(三):独占锁(Exclusive Lock)

    一.前言 优秀的源码就在那里 经过了前面两章的铺垫,终于要切入正题了,本章也是整个AQS的核心之一 从本章开始,我们要精读AQS源码,在欣赏它的同时也要学会质疑它.当然本文不会带着大家逐行过源码(会有 ...

  6. Mysql讲解数据库并发控制知识

    1.下载Mysql并安装,我喜欢不用安装的zip版,cd到bin目录下,先修改下mysql的密码. mysqladmin -u root -p password mysql ,第一次运行并修改mysq ...

  7. 使用next-key locks 用于搜索和索引扫描,可以防止幻读

    Next-Key Locks A next-key lock is a combination of a record lock on the index record and a gap lock ...

  8. MySQL 基础知识梳理学习(六)----锁

    1.什么是锁: 对共享资源进行并发访问控制,提供数据的完整性和一致性. 2.锁的区别: 类型 lock latch 对象 事务 线程 保护 数据库内容 内存数据结构 持续时间 整个事务过程 临界资源 ...

  9. 转 MYSQL InnoDB Record, Gap, and Next-Key Locks

    http://dev.mysql.com/doc/refman/5.0/en/innodb-record-level-locks.html InnoDB has several types of re ...

随机推荐

  1. Google代码实验室

    https://code.google.com/p/google-styleguide/

  2. Android(java)学习笔记203:网页源码查看器(Handler消息机制)

    1.项目框架图: 2.首先是布局文件activity_main.xml: <LinearLayout xmlns:android="http://schemas.android.com ...

  3. SPFA 小优化*2

    /* bzoj 2763 SPFA小优化 循环队列+SLF 顺面改掉自己之前手打qeueu的坏毛病*/ #include<iostream> #include<cstring> ...

  4. html获取gps坐标

    <script> function getLocation(){ var options={ enableHighAccuracy:true, maximumAge:1000 } if(n ...

  5. 读取xml时,遇到xmlns的问题

    1.读取xml的时候,由于xml里有xmlns的属性,导致了读xml无法正常读取.通过网上搜索,发现需要先注册命名空间.  xmlns是XML Namespaces的缩写,中文名称是XML(标准通用标 ...

  6. Wireshark提示没有一个可以抓包的接口

    这是由于win下默认NPF服务是关闭的,需要以管理员的身份开启这个服务 Windows上安装wireshark时,会遇到NPF驱动无法启动的情况,一般如果采用管理员的方式就可以正常启动,或者是将NPF ...

  7. 从XML文件中获取格式化的文本信息

    在FMW的运维过程中,时常需要将中间传输的XML信息转换为excel格式化的问题提交给关联系统人员,现总结三种格式化问题提供方式 一.使用Excel转换 因为从系统中取到的xml文档为中间信息文档,需 ...

  8. SGU 142.Keyword

    时间限制:0.5s 空间限制:16M 题意 给出一个仅由'a',‘b’组成的字符串S,长度小于500 000,求一个由‘a’,‘b’组成的不是S子串的字符串T. 输出T的长度和T. Sample In ...

  9. SGU 164.Airline(结论题)

    时间限制:0.25s 空间限制:4M 题意: 在n(1<=n<=200)个点的无向完全图中,有m种不同的边.现在从中选择不超过(m+1)/2种边,使得任意两点可以通过不超过3条边互相到达. ...

  10. 【NOI2004】郁闷的出纳员

    [问题描述] OIER公司是一家大型专业化软件公司,有着数以万计的员工.作为一名出纳员,我的任务之一便是统计每位员工的工资.这本来是一份不错的工作,但是令人郁闷的是,我们的老板反复无常,经常调整员工的 ...