如何清除交易僵局?

问题描述 投票:17回答:3

使用'show engine innodb status',我看到wordpress有两个死锁。我想清除这些错误,但我没有看到任何一个有效的cmd进程(例如,有一些“杀死”并希望强制回滚的东西)。

我可以看到线程ID,查询ID等,但是我无法用来停止任何一项工作。

有关如何解决此问题的建议?

编辑:这是状态的(相关?)部分:

------------------------
LATEST DETECTED DEADLOCK
------------------------
110327 10:54:14
*** (1) TRANSACTION:
TRANSACTION 9FBA099E, ACTIVE 0 sec, process no 14207, OS thread id 1228433728 starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 376, 1 row lock(s)
MySQL thread id 12505112, query id 909492800 juno....edu 129....54 wordpress_user updating
DELETE FROM wp_options WHERE option_name = ''_site_transient_timeout_theme_roots''
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 4951009 page no 4 n bits 384 index `option_name` of table `wordpress_work`.`wp_options` trx id 9FBA099E lock_mode X waiting
Record lock, heap no 309 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
0: len 30; hex 5f736974655f7472616e7369656e745f74696d656f75745f7468656d655f; asc _site_transient_timeout_theme_; (total 35 bytes);
1: len 8; hex 0000000000002b6d; asc       +m;;

*** (2) TRANSACTION:
TRANSACTION 9FBA0995, ACTIVE 0 sec, process no 14207, OS thread id 1230031168 starting index read
mysql tables in use 1, locked 1
3 lock struct(s), heap size 1248, 2 row lock(s)
MySQL thread id 12505095, query id 909492789 juno....edu 129.....54 wordpress_user updating
DELETE FROM wp_options WHERE option_name = ''_site_transient_timeout_theme_roots''
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 4951009 page no 4 n bits 384 index `option_name` of table `wordpress_work`.`wp_options` trx id 9FBA0995 lock_mode X locks rec but not gap
Record lock, heap no 309 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
0: len 30; hex 5f736974655f7472616e7369656e745f74696d656f75745f7468656d655f; asc   _site_transient_timeout_theme_; (total 35 bytes);
 1: len 8; hex 0000000000002b6d; asc       +m;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 4951009 page no 4 n bits 384 index `option_name` of table     `wordpress_work`.`wp_options` trx id 9FBA0995 lock_mode X waiting
Record lock, heap no 309 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
0: len 30; hex 5f736974655f7472616e7369656e745f74696d656f75745f7468656d655f; asc   _site_transient_timeout_theme_; (total 35 bytes);
1: len 8; hex 0000000000002b6d; asc       +m;;

*** WE ROLL BACK TRANSACTION (1)
mysql deadlock
3个回答
22
投票

给出如下“ innodb status”输出:

---TRANSACTION 0 0, not started, process no 1024, OS thread id 140386055603968
MySQL thread id 197, query id 771 localhost marc
show innodb status

您想做

KILL QUERY 771

杀死两个死锁的查询之一。这样可以终止查询,但保持连接打开状态。如果要终止连接,则可以执行KILL 197


11
投票

使用'show engine innodb status',我发现wordpress有两个死锁...有关如何解决此问题的建议?

我想提供更多的信息,这些信息将有助于我们解决类似的问题。我们看到了Java休眠问题,导致卡死。我们通过梳理以下来源的输出找到了锁:

show engine innodb status;

这会吐出大量的信息。相关部分在TRANSACTIONS部分中。在您的输出中,相关的问题似乎是:

3 lock struct(s), heap size 1248, 2 row lock(s)
MySQL thread id 12505095, query id 909492789 juno....edu 129.....54 

对我们来说,这是# lock struct(s)表示卡住了。要杀死它,您需要使用指定的“线程ID#”执行-在这种情况下:

kill 12505095

这适用于AWS MySQL RDS以及本地MySQL。

在“交易”部分中,我们还会看到以下内容:

---TRANSACTION 644793773, ACTIVE 21 sec
2 lock struct(s), heap size 360, 1 row lock(s)
MySQL thread id 217, OS thread handle 0x2aef097700, query id 10177 1.3.5.7 mpsp cleaning up

我们同时寻找2 lock struct(s)ACTIVE 21 sec消息。


7
投票

我知道这很旧,但是通常当您看到这样的信息时,是因为发生了死锁,并且触发死锁的应用已经很久了-死锁的受害者被警告并且失败,或者记录了错误或重试,无论哪种方式都已转移到其他生产性产品上。如果您正在编写软件,那么除了查看死锁的原因并尝试避免将来的死锁之外,您通常不需要执行任何其他操作。如果您仅使用该软件(例如,如果您不在Wordpress上工作,则使用Wordpress),则可以将死锁报告为可能的错误。

© www.soinside.com 2019 - 2024. All rights reserved.