我在Amazon EC2实例上运行了一个WordPress网站,在过去的几个星期里,网站每隔3-4天一直在早上崩溃。我看了一下Apache和MYSQL日志,看起来我有一个反复出现的死锁。
以下是Apache日志中的代码示例:
[Sun Feb 19 20:02:16.224985 2017] [:error] [pid 56] [client 191.96.249.70:42601] WordPress database error Deadlock found when trying to get lock; try restarting transaction for query DELETE FROM `wp_options` WHERE `option_name` = '_transient_jetpack_idc_allowed' made by include('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), include_once('/plugins/jetpack/jetpack.php'), require_once('/plugins/jetpack/class.jetpack-idc.php'), Jetpack_IDC::init, Jetpack_IDC->__construct, Jetpack::check_identity_crisis, Jetpack::validate_sync_error_idc_option, get_transient, delete_option
这一连续反复重复 这是SQL日志中的代码:
------------------------
LATEST DETECTED DEADLOCK
------------------------
2017-02-19 20:02:16 0x7fc8b8734700
*** (1) TRANSACTION:
TRANSACTION 3450375, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 1136, 1 row lock(s)
MySQL thread id 3, OS thread handle 140500064950016, query id 53 localhost sqluser updating
DELETE FROM `wp_options` WHERE `option_name` = '_transient_jetpack_idc_allowed'
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 162 page no 49 n bits 400 index option_name of table `wordpress`.`wp_options` trx id 3450375 lock_mode X locks rec but not gap waiting
Record lock, heap no 325 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
0: len 30; hex 5f7472616e7369656e745f6a65747061636b5f6964635f616c6c6f776564; asc _transient_jetpack_idc_allowed;;
1: len 8; hex 000000000000563c; asc V<;;
*** (2) TRANSACTION:
TRANSACTION 3450373, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
3 lock struct(s), heap size 1136, 2 row lock(s)
MySQL thread id 2, OS thread handle 140500064749312, query id 49 localhost sqluser updating
DELETE FROM `wp_options` WHERE `option_name` = '_transient_jetpack_idc_allowed'
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 162 page no 49 n bits 400 index option_name of table `wordpress`.`wp_options` trx id 3450373 lock_mode X locks rec but not gap
Record lock, heap no 325 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
0: len 30; hex 5f7472616e7369656e745f6a65747061636b5f6964635f616c6c6f776564; asc _transient_jetpack_idc_allowed;;
1: len 8; hex 000000000000563c; asc V<;;
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 162 page no 49 n bits 400 index option_name of table `wordpress`.`wp_options` trx id 3450373 lock_mode X waiting
Record lock, heap no 325 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
0: len 30; hex 5f7472616e7369656e745f6a65747061636b5f6964635f616c6c6f776564; asc _transient_jetpack_idc_allowed;;
1: len 8; hex 000000000000563c; asc V<;;
*** WE ROLL BACK TRANSACTION (1)
它还打印了许多其他东西,但我相信这是相关的代码。告诉我,如果我错了,我也需要查看其他内容。
我怀疑它与Jetpack有关,因为它被提及,所以我禁用Jetpack,但该网站仍然死亡,虽然有更多神秘的错误。有人能在这里给我任何见解吗?该网站已经持续了几个月,但最近刚刚开始发生。我不确定为什么这是一个反复出现的问题。
另外,如果我应该在WordPress stackexchange上发布这个,请告诉我。