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的更多相关文章

  1. 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 ...

  2. 14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小

    14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小 这个章节描述如何增加或者减少 InnoDB 系统表空间的大小 增加InnoDB ...

  3. 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 是一个线程 执行各种任务在后台. ...

  4. 14.6.3.5 Configuring InnoDB Buffer Pool Flushing

    14.6.3.5 Configuring InnoDB Buffer Pool Flushing InnoDB 执行某些任务在后台, 包括脏叶的刷新(那些已经发生改变的pages 但是没有写入到数据文 ...

  5. 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/ ...

  6. 14.6.3.1 The InnoDB Buffer Pool

    14.6.3.1 The InnoDB Buffer Pool InnoDB 保持一个存储区域被称为buffer pool 用于cache数据和索引在内存里, 知道InnoDB buffer pool ...

  7. 14.5.5.1 An InnoDB Deadlock Example 一个InnoDB 死锁实例

    14.5.5.1 An InnoDB Deadlock Example 一个InnoDB 死锁实例 下面的例子演示了一个错误可以发生当一个lock 请求会导致一个死锁,例子设计2个客户端,A和B: J ...

  8. 14.6.7?Limits on InnoDB Tables InnoDB 表的限制

    14.6.7?Limits on InnoDB Tables InnoDB 表的限制 警告: 不要把MySQL system tables 从MyISAM 到InnoDB 表. 这是不支持的操作,如果 ...

  9. 14.1.3 Turning Off InnoDB 关掉InnoDB

    14.1.3 Turning Off InnoDB 关掉InnoDB: Oracle 推荐InnoDB 作为首选的存储引擎用于典型的数据库应用,从单用户的wikis到博客, 到高端应用把性能推到极限. ...

随机推荐

  1. [iOS 开发] Xcode常见报错及解决办法

    报错一: 在iOS7的真机运行时,弹出错误:App installation failed. There was an internal API error. 如图 解决办法: 在Xcode -> ...

  2. Oracle创建存储过程、执行存储过程基本语法

    >>>>>>>>>>>>>>>>>>>>>>>>> ...

  3. replace()、replaceFirst()和replaceAll()的区别

    1.replace() String str= "mesquite in your cellar" str.replace('e', 'o') returns "mosq ...

  4. PHP解决多进程同时读写一个…

    原文地址:PHP解决多进程同时读写一个文件的问题作者:陌上花开 首先PHP是支持进程的而不支持多线程(这个先搞清楚了),如果是对于文件操作,其实你只需要给文件加锁就能解决,不需要其它操作,PHP的fl ...

  5. Java-hibernate的映射文件

    Hibernate 需要知道怎样去加载(load)和存储(store)持久化类的对象.这正是 Hibernate 映 射文件发挥作用的地方.映射文件告诉 Hibernate 它应该访问数据库(data ...

  6. java 执行sql脚本的3种方式 (ant,ibatis,ScriptRunner)

    package com.unmi; import java.io.*; import org.apache.tools.ant.*; import org.apache.tools.ant.taskd ...

  7. SQL Server备份还原数据库中的小把戏

    备份数据库时出现一个不太了解的错误 ,错误信息“is formatted to support  1 media families, but 2 media families are expected ...

  8. jQuery无刷新上传学习心得

    记得刚离开大学,进入目前这家公司不到一个月时,有一位前辈给我们当时的新人讲了下JS无刷新上传的相关知识. 在此之前,一直都是在使用C#提供的服务器上传控件FileUpload,但是每次使用时,都会刷新 ...

  9. Lost connection to MySQL server at ‘reading initial communication packet', system error: 0 mysql远程连接问题

    在用Navicat for MySQL远程连接mysql的时候,出现了 Lost connection to MySQL server at ‘reading initial communicatio ...

  10. [Lua]cocos framework

    package_support function cc.register(name, package) function cc.load(...) function cc.bind(target, . ...