码迷,mamicode.com
首页 > 其他好文 > 详细

pt-online-schema-change 修改字段属性产生死锁

时间:2015-06-17 02:04:09      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:discount   setting   thread   amount   tables   

  1. 死锁信息如下:


2015-06-15 22:23:18 7f0266772700

*** (1) TRANSACTION:

TRANSACTION 1834696957, ACTIVE 0 sec setting auto-inc lock

mysql tables in use 2, locked 2

LOCK WAIT 4 lock struct(s), heap size 1184, 1 row lock(s), undo log entries 1

MySQL thread id 1008989, OS thread handle 0x7f0265de0700, query id 1925131733 127.0.0.1 huanghualiang Sending data

INSERT LOW_PRIORITY IGNORE INTO `newmall`.`_cash_xxx_new` (`id`, `type`, `name`, `discount`, `amount`, `begintime`, `endtime`, `userid`, `realname`, `code`, `releaseuserid`, `releaseorderid`, `orderid`, `status`, `packetid`, `deleted`, `createtime`, `updatetime`, `openid`, `headimgurl`) SELECT `id`, `type`, `name`, `discount`, `amount`, `begintime`, `endtime`, `userid`, `realname`, `code`, `releaseuserid`, `releaseorderid`, `orderid`, `status`, `packetid`, `deleted`, `createtime`, `updatetime`, `openid`, `headimgurl` FROM `newmall`.`cash_xxx` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ‘168256‘)) AND ((`id` <= ‘174595‘)) LOCK IN SHARE MODE /*pt-online-schema-change 17123 copy nibble*/

*** (1) WAITING FOR THIS LOCK TO BE GRANTED:

TABLE LOCK table `newmall`.`_cash_xxx_new` trx id 1834696957 lock mode AUTO-INC waiting

*** (2) TRANSACTION:

TRANSACTION 1834696069, ACTIVE 1 sec fetching rows, thread declared inside InnoDB 2131

mysql tables in use 2, locked 2

1580 lock struct(s), heap size 161320, 3 row lock(s), undo log entries 2

MySQL thread id 1007462, OS thread handle 0x7f0266772700, query id 1925130797 10.162.216.179 xm_mall closing tables

update `cash_xxx` set status = 2 where orderId = 3271393

*** (2) HOLDS THE LOCK(S):

TABLE LOCK table `newmall`.`_cash_xxx_new` trx id 1834696069 lock mode AUTO-INC

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 11019 page no 3462 n bits 184 index `PRIMARY` of table `newmall`.`cash_xxx` trx id 1834696069 lock_mode X locks rec but not gap waiting

*** WE ROLL BACK TRANSACTION (1)



事务1: INSERT LOW_PRIORITY IGNORE INTO `newmall`.`_cash_xxx_new` ....... select ... FROM `newmall`.`cash_xxx` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= ‘168256‘)) AND ((`id` <= ‘174595‘)) LOCK IN SHARE MODE;


wait for:  _cash_xxx_new  自增主键表级别锁

hold:     cash_xxx 表的S锁


事务2:update `cash_xxx` set status = 2 where orderId = 3271393

wait for:cash_xxx 表的X锁

hold:    _cash_xxx_new 的自增锁  (这里是因为pt-online-schema-change 触发器把update 转成replace into 新表)


最后回滚了事务1。

本文出自 “My DBA life” 博客,请务必保留此出处http://huanghualiang.blog.51cto.com/6782683/1662474

pt-online-schema-change 修改字段属性产生死锁

标签:discount   setting   thread   amount   tables   

原文地址:http://huanghualiang.blog.51cto.com/6782683/1662474

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!