14.5.5 Deadlocks in InnoDB
14.5.5 Deadlocks in InnoDB 14.5.5.1 An InnoDB Deadlock Example
14.5.5.2 Deadlock Detection and Rollback
14.5.5.3 How to Minimize and Handle Deadlocks 死锁是一种情况 不同的事务是不能处理 因为每个持有的lock 是其他会话需要的。 因为所有事务都是等待一个资源变得可用,两者都不释放它持有的锁 一个deadlock 可以发生 当事务锁定记录在多个表(通过语句比如UPDATE or SELECT ... FOR UPDATE), 但是相反的顺序,一个deadlock 也可以发生当语句锁定 index记录的范围和区间, 每个事务需要一些locks. 为了减少死锁的可能,使用事务而不是LOCK TABLES 语句, 让事务插入和更新数据足够小 他们不会唱时间保持打开; 当不同的事务更新多个表或者大量的记录,使用相同的操作顺序(比如SELECT ... FOR UPDATE) 在每个事务 创建索引在列上用于SELECT ... FOR UPDATE and UPDATE ... WHERE 自居。 死锁的可能不受事务隔离的影响,因为事务隔离改变了读操作的行为, 而死锁发生因为是写操作。 如果一个死锁发生,InnoDB检测状态和回滚其中一个事务。 因此, 即使你的应用逻辑是正确的,你必须仍旧处理案例当一个事务必须是重试。 看最新的死锁信息在InnoDB 用户事务,
SHOW ENGINE INNODB STATUS\G;
LATEST DETECTED DEADLOCK
------------------------
2016-10-28 17:59:20 7f4acb87f700
*** (1) TRANSACTION:
TRANSACTION 14917, ACTIVE 3180 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 5 lock struct(s), heap size 2936, 2 row lock(s), undo log entries 6
MySQL thread id 2, OS thread handle 0x7f4acb8c0700, query id 555 localhost root update
insert into t1 values(10)
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 580 page no 3 n bits 72 index `PRIMARY` of table `zjzc`.`t1` trx id 14917 lock_mode X insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len 8; hex 73757072656d756d; asc supremum;; *** (2) TRANSACTION:
TRANSACTION 14919, ACTIVE 5 sec inserting
mysql tables in use 1, locked 1
4 lock struct(s), heap size 1184, 2 row lock(s)
MySQL thread id 3, OS thread handle 0x7f4acb87f700, query id 556 localhost root update
insert into t1 values(10)
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 580 page no 3 n bits 72 index `PRIMARY` of table `zjzc`.`t1` trx id 14919 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;; *** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 580 page no 3 n bits 72 index `PRIMARY` of table `zjzc`.`t1` trx id 14919 lock_mode X insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len 8; hex 73757072656d756d; asc supremum;; *** WE ROLL BACK TRANSACTION (2)
14.5.5 Deadlocks in 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.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小
14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小 这个章节描述如何增加或者减少 InnoDB 系统表空间的大小 增加InnoDB ...
- 14.6.8 Configuring the InnoDB Master Thread IO Rate 配置InnoDB 主线程IO 速率:
14.6.8 Configuring the InnoDB Master Thread IO Rate 配置InnoDB 主线程IO 速率: 主线程 在InnoDB 是一个线程 执行各种任务在后台. ...
- 14.6.3.5 Configuring InnoDB Buffer Pool Flushing
14.6.3.5 Configuring InnoDB Buffer Pool Flushing InnoDB 执行某些任务在后台, 包括脏叶的刷新(那些已经发生改变的pages 但是没有写入到数据文 ...
- 14.6.3.4 Configuring InnoDB Buffer Pool Prefetching (Read-Ahead) 配置InnoDB Buffer pool 预取
14.6.3.4 Configuring InnoDB Buffer Pool Prefetching (Read-Ahead) 配置InnoDB Buffer pool 预取 一个预读请求是一个I/ ...
- 14.6.3.1 The InnoDB Buffer Pool
14.6.3.1 The InnoDB Buffer Pool InnoDB 保持一个存储区域被称为buffer pool 用于cache数据和索引在内存里, 知道InnoDB buffer pool ...
- 14.5.5.1 An InnoDB Deadlock Example 一个InnoDB 死锁实例
14.5.5.1 An InnoDB Deadlock Example 一个InnoDB 死锁实例 下面的例子演示了一个错误可以发生当一个lock 请求会导致一个死锁,例子设计2个客户端,A和B: J ...
- 14.6.7?Limits on InnoDB Tables InnoDB 表的限制
14.6.7?Limits on InnoDB Tables InnoDB 表的限制 警告: 不要把MySQL system tables 从MyISAM 到InnoDB 表. 这是不支持的操作,如果 ...
- 14.1.3 Turning Off InnoDB 关掉InnoDB
14.1.3 Turning Off InnoDB 关掉InnoDB: Oracle 推荐InnoDB 作为首选的存储引擎用于典型的数据库应用,从单用户的wikis到博客, 到高端应用把性能推到极限. ...
随机推荐
- yo bootstrap mui 使用对比
昨天晚上 又被问及职业发展方向,提及我的老本行css,切了几年的页面,近两年投入进css的时间屈指可数,被问及之前公司用的yo框架 对比业界内其他css 框架的优势. 1. yo模块化,碎片化 可自 ...
- js移除最后一个字符,js替换字符串的连接符号,js移除最后一个分隔符号
js移除最后一个字符 js移除最后一个分隔符号 js替换字符串的连接符号 >>>>>>>>>>>>>>>> ...
- oracle 11g 安装及网络配置
非原创,纯属笔记 安装:基本按照默认下一步安装的 1)可执行安装文件[ setup.exe ]双击安装 2):配置安全更新,取消下面的“我希望通过My Oracle Support接受安全更新(W)” ...
- phpstrtotime()对于31日求上个月有问题
PHP自带的strtotime()对于31日求上个月有问题,如下: <?php $date = "2012-07-31"; $date_unix = strtotime($d ...
- 使用Druid作为数据源
Druid号称是Java语言中最好的数据库连接池. 1) 可以监控数据库访问性能,Druid内置提供了一个功能强大的StatFilter插件,能够详细统计SQL的执行性能,这对于线上分析数据库访问性能 ...
- listview中button抢占焦点问题
解决办法Item xml 根节点添加 android:descendantFocusability="blocksDescendants" Button 设置 android:fo ...
- 设计webapp的新思路
一般设计移动应用有3中方式:原生.脚本.混合:今天我们用另一种方式实现. 我叫它:响应式网页webApp 一.具体构架思路是这样的: 客户端:Android手机 Android手机中有控件WebVie ...
- Android - 服务器json数据交互.
一,服务器端 服务器端使用的是Servlet,封装json对象使用的 'json-lib-2.2.2-jdk15.jar,ezmorph-1.0.4.jar,commons-logging-1.1.j ...
- .NET下的加密解密大全(3):非对称加密
本博文列出了.NET下常用的非对称加密算法,并将它们制作成小DEMO,希望能对大家有所帮助. RSA[csharp]static string EnRSA(string data,string pub ...
- why slow thinking wins
今天Hacker News上的一篇文章<为什么想得慢的人能赢>引起了广泛的讨论. 网友Scott Burson在文章后评论说:"之前,我雇佣了一位TopCoder冠军,原本预计他 ...