【问题标题】:Issue with deadlock and lock timeout exceeded on mysqlmysql 上超过死锁和锁定超时的问题
【发布时间】:2018-05-12 10:02:01
【问题描述】:

好吧,我在一些更新、删除和插入方面遇到了麻烦。

我发现在 mysql 上输入 SHOW ENGINE INNODB STATUS 会显示最后一个死锁:

------------------------
LATEST DETECTED DEADLOCK
------------------------
171128  2:10:22
*** (1) TRANSACTION:
TRANSACTION 23 2653931321, ACTIVE 3 sec, process no 19519, OS thread id 123471633422080 inserting
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 1216, 2 row lock(s), undo log entries 1
MySQL thread id 57910754, query id 25462868783 localhost 127.0.0.1 ***** update
INSERT IGNORE INTO tb01 (`id_agendamento`,`nm_usuario`,`id_usuario`,`dt_cache`) values ('3000373','fulano','27861269','2017-11-28 02:10:19')
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 6137 page no 54196 n bits 672 index `id_agendamento` of table `dbinfos`.`tb01` trx id 23 2653931321 lock mode S waiting
Record lock, heap no 259 PHYSICAL RECORD: n_fields 3; compact format; info bits 32
 0: len 3; hex adc835; asc   5;; 1: len 8; hex 3237383631323639; asc 27861269;; 2: len 4; hex 80921b71; asc    q;;

*** (2) TRANSACTION:
TRANSACTION 23 2653285408, ACTIVE 143 sec, process no 19519, OS thread id 123471351097088 fetching rows, thread declared inside InnoDB 468
mysql tables in use 1, locked 1
109238 lock struct(s), heap size 13187056, 26792384 row lock(s), undo log entries 12217038
MySQL thread id 57906706, query id 25461633354 localhost 127.0.0.1 ***** updating
DELETE from tb01 WHERE dt_cache < DATE_ADD(CURDATE(), INTERVAL -1 DAY)
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 6137 page no 54196 n bits 672 index `id_agendamento` of table `dbinfos`.`tb01` trx id 23 2653285408 lock_mode X locks rec but not gap
Record lock, heap no 259 PHYSICAL RECORD: n_fields 3; compact format; info bits 32
 0: len 3; hex adc835; asc   5;; 1: len 8; hex 3237383631323639; asc 27861269;; 2: len 4; hex 80921b71; asc    q;;

但我不明白如何解决它。

【问题讨论】:

  • 不适合 SO。经过更多研究,如果仍有合适的问题,建议前往dba.stackexchange.com 这是回答这个问题的好地方,顺便说一句。

标签: php mysql centos


【解决方案1】:

这里只是一个疯狂的猜测,但您不只是在代码中打开一个事务并在保持打开状态后做一些繁重的工作吗?

如果不是,那么是的,dba.stackexchange 可能是最好的提问地点。

【讨论】:

    猜你喜欢
    • 2015-09-20
    • 2011-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 2011-12-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多