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. Jquery调用从ashx文件返回的jsonp格式的数据处理实例

    开发环境:vs2010+jquery-1.4.min.js 解决问题:网上代码比较少,好多调试不通,返回数据不用json而用jsonp主要考虑解决跨域问题 开发步骤:打开VS2010,新建一web站点 ...

  2. PHP 时间函数集合

    计算指定日期的前几天,几个月或者几年的函数 $a = '2014/08/21';echo date( "Y-m-d", strtotime( "-6 month  &qu ...

  3. LINQ 多条件写法

    源代码: string depAll = (ddl_dep1.SelectedValue == "") ? "" : ddl_dep1.SelectedValu ...

  4. JavaScript上下文和闭包

    "this" 上下文 上下文通常是取决于一个函数如何被调用.当函数作为对象的方法被调用时,this 被设置为调用方法的对象: var object = { foo: functio ...

  5. 去掉Visual Studio 编辑器里中文注释的红色波浪线 转载

    我们通常用visual studio进行开发的时候,我们通常会用到一款比较流行比较方便的插件,那就是Visual Assist X,它可以增强Microsoft开发环境下的编辑能力,支持C/C++,C ...

  6. WinSock 异步I/O模型 转载

    如果你想在Windows平台上构建服务器应用,那么I/O模型是你必须考虑的.Windows操作系统提供了五种I/O模型,分别是: ■ 选择(select):■ 异步选择(WSAAsyncSelect) ...

  7. c++相关知识回顾

    1.typedef typedef用来定义同类型的同义词.如: typedef unsingned int size_t; typedef int ptrdiff_t; typedef T * ite ...

  8. Apache 支持PHP

    ①加载PHP模块到Apache中: LoadModule php5_module "d:\php5\php5apache2_2.dll"   ②加入识别扩展名为.php文件(也可以 ...

  9. decimall类型数据

    同样是decimal(18,5)   和 decimal(18,4)  在VB中经过几次转化过后,数据就有可能改变. 遇到的情况 decimal(18,5)到  decimal(18,4)转换过程中数 ...

  10. eclipse/myeclipse选中编辑区域文件,Package Explorer定位文件所在项目及目录

    eclipse/myeclipse选中编辑区域文件,Package Explorer定位文件所在项目及目录 1. 打开Package Explorer(若没有,可以按照如下路径点击: Window菜单 ...