14.5.5.1 An InnoDB Deadlock Example 一个InnoDB 死锁实例
14.5.5.1 An InnoDB Deadlock Example 一个InnoDB 死锁实例 下面的例子演示了一个错误可以发生当一个lock 请求会导致一个死锁,例子设计2个客户端,A和B: Jekins:/root# mysql -uroot -p1234567 -e"SHOW ENGINE INNODB STATUS\G;" | grep -i dead
Warning: Using a password on the command line interface can be insecure. 首先, client A 创建一个表包含一个记录, 然后开始一个事务,在事务中,通过selecting在共享模式得到一个S锁 mysql> CREATE TABLE t (i INT) ENGINE = InnoDB;
Query OK, 0 rows affected (1.07 sec) mysql> INSERT INTO t (i) VALUES(1);
Query OK, 1 row affected (0.09 sec) mysql> START TRANSACTION;
Query OK, 0 rows affected (0.00 sec) mysql> SELECT * FROM t WHERE i = 1 LOCK IN SHARE MODE;
+------+
| i |
+------+
| 1 |
+------+ 接着,Client B 开始一个事务和尝试删除记录 mysql> START TRANSACTION;
Query OK, 0 rows affected (0.00 sec) mysql> DELETE FROM t WHERE i = 1; 删除操作需要一个X锁,lock 不能被立即授权 因为它不兼容S锁 客户端A持有的, 最后,Client A 尝试删除表的记录 mysql> DELETE FROM t WHERE i = 1;
ERROR 1213 (40001): Deadlock found when trying to get lock;
try restarting transaction Deadlock 发生 因为client A 需要一个X锁来删除记录。 然而,lock 请求不能被立即授予因为Client B有一个请求X锁 在等待客户端A 来释放他的S锁。 S锁被client A持有的也不能升级为X锁 。这样,InnoDB 产生一个错误 ------------------------
LATEST DETECTED DEADLOCK
------------------------
2016-10-31 10:06:09 7f0341d30700
*** (1) TRANSACTION:
TRANSACTION 15945, ACTIVE 5 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 360, 1 row lock(s)
MySQL thread id 5, OS thread handle 0x7f0341ae9700, query id 368 localhost root updating
DELETE FROM t WHERE i = 1
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 583 page no 3 n bits 72 index `GEN_CLUST_INDEX` of table `zjzc`.`t` trx id 15945 lock_mode X waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 6; hex 000000005c00; asc \ ;;
1: len 6; hex 000000003e47; asc >G;;
2: len 7; hex c7000001be0110; asc ;;
3: len 4; hex 80000001; asc ;; *** (2) TRANSACTION:
TRANSACTION 15944, ACTIVE 24 sec starting index read
mysql tables in use 1, locked 1
4 lock struct(s), heap size 1184, 3 row lock(s)
MySQL thread id 4, OS thread handle 0x7f0341d30700, query id 369 localhost root updating
DELETE FROM t WHERE i = 1
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 583 page no 3 n bits 72 index `GEN_CLUST_INDEX` of table `zjzc`.`t` trx id 15944 lock mode S
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len 8; hex 73757072656d756d; asc supremum;; Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 6; hex 000000005c00; asc \ ;;
1: len 6; hex 000000003e47; asc >G;;
2: len 7; hex c7000001be0110; asc ;;
3: len 4; hex 80000001; asc ;; *** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 583 page no 3 n bits 72 index `GEN_CLUST_INDEX` of table `zjzc`.`t` trx id 15944 lock_mode X waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 6; hex 000000005c00; asc \ ;;
1: len 6; hex 000000003e47; asc >G;;
2: len 7; hex c7000001be0110; asc ;;
3: len 4; hex 80000001; asc ;; *** WE ROLL BACK TRANSACTION (1)
14.5.5.1 An InnoDB Deadlock Example 一个InnoDB 死锁实例的更多相关文章
- 14.3.5.1 An InnoDB Deadlock Example
14.3.5 Deadlocks in InnoDB 14.3.5.1 An InnoDB Deadlock Example 14.3.5.2 Deadlock Detection and Rollb ...
- 14.3.5.2 Deadlock Detection and Rollback 死锁检测和回滚:
14.3.5.2 Deadlock Detection and Rollback 死锁检测和回滚: InnoDB 自动检查四艘,回滚一个事务或者事务来打破死锁. InnoDB 试图选择小的事务来回滚, ...
- 14.8.2 Role of the .frm File for InnoDB Tables InnoDB 表得到 .frm文件的作用
14.8.2 Role of the .frm File for InnoDB Tables InnoDB 表得到 .frm文件的作用 Vsftp:/data01/mysql/zjzc# ls -lt ...
- 14.7.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量和大小
14.7.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量和大小 改变 InnoDB ...
- 14.6.7 Configuring the Number of Background InnoDB IO Threads 配置InnoDB IO Threads的数量
14.6.7 Configuring the Number of Background InnoDB IO Threads 配置InnoDB IO Threads的数量 InnoDB 使用后台线程来服 ...
- 14.6.5 Configuring InnoDB Change Buffering 配置InnoDB Change Buffering
14.6.5 Configuring InnoDB Change Buffering 配置InnoDB Change Buffering 当插入,更新,和删除操作在表上执行, 索引列的值(特别是 se ...
- 14.19 InnoDB and MySQL Replication InnoDB 和MySQL 复制:
14.19 InnoDB and MySQL Replication InnoDB 和MySQL 复制: MySQL 复制工作对于InnoDB 表和对于MyISAM表. 它是可能使用复制的方式 存储引 ...
- 14.5.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量
14.5.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量 改变InnoDB redo ...
- 14.4.5 Configuring InnoDB Change Buffering 配置InnoDB Change Buffering
14.4.5 Configuring InnoDB Change Buffering 配置InnoDB Change Buffering 当INSERT,UPDATE,和删除操作在表上操作, 索引列的 ...
随机推荐
- CSS hack常用方案(摘选)
邮箱因为默认了line-height?:170%,导致采用table元素时继承问题,可以采用line-height:50% 很好解决. 常 在使用float时,后面的显示不正常,因为继承了float了 ...
- Entity Framework Demo(一) 简单搭建环境
Entity Framwork(实体框架,简称EF)是ORM(Object Relational Mapping,对象映射关系)的一个解决方案. EF允许项目将数据库的表映射为实体,并封装了操作方法, ...
- GridView分页的实现
要在GridView中加入 //实现分页 AllowPaging="true" //一页数据10行 PageSize="10" // 分页时触发的事件 OnPa ...
- 新浪微博failed to receive access token
这个问题很多人都遇到了,很多人发邮件我,我之前解决的时候也花了很大的代价,发现很多的都是抄袭,然后就是找不到答案,确实比较痛苦.避免大家跟我范一样的错误. 保证几个东西: 1.签名正确---非常重要. ...
- js - 多个函数动态加载
//动态添加物流锁的IEMI列表. function createLi() { var r = '<s:property value="#session.locks"/> ...
- .NET下的加密解密大全(3):非对称加密
本博文列出了.NET下常用的非对称加密算法,并将它们制作成小DEMO,希望能对大家有所帮助. RSA[csharp]static string EnRSA(string data,string pub ...
- ASP.NET页面生命周期总结(完结篇)
补充: W3svc服务 负责把‘工作进程’启动起来 W3svc 连接工作进程.内核模块.IIS 主服务的一个核心的桥梁 W3svc还有一个作用就是维护应用程序池,可以设置多长时间回收,多长时间重启. ...
- Tomcat启动后加载两次web.xml的问题(因为spring定时任务执行了俩次,引出此问题)
http://www.linuxidc.com/Linux/2011-07/38779.htmhttp://jingyan.baidu.com/article/48206aeaf9422e216ad6 ...
- 解决IE无法解析json的方法
一.原始方法eval() 二.json插件--github开源插件:json-js/json2.js https://github.com/douglascrockford/JSON-js/blob/ ...
- iOS支付总结
内容大纲: 一.常见的支付方案简介 二.第三方支付SDK 三.苹果官方支付方案 四.Web支付方案 正文: 一.常见的支付方案简介 在微信支付中 微信支付的网址是: https://pay.weixi ...