我们有一个Symphony2 Web应用程序,并使用Doctrine作为ORM。
后端我们将AWS RDS MySQL与InnoDB引擎结合使用。
SHOW VARIABLES LIKE "%version%";
innodb_version 5.6.22
protocol_version 10
slave_type_conversions
version 5.6.22-log
version_comment MySQL Community Server (GPL)
version_compile_machine x86_64
version_compile_os Linux
我们可以通过反复单击提交按钮来触发数据库服务器上的意外死锁。 这是我们收到的错误消息的一部分:
------------------------
LATEST DETECTED DEADLOCK
------------------------
2015-06-16 07:13:17 2aebdd723700
*** (1) TRANSACTION:
TRANSACTION 2009024, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 3 lock struct(s), heap size 360, 1 row lock(s), undo log entries 2
MySQL thread id 11125, OS thread handle 0x2aebdd6e2700, query id 1666530 172.31.26.135 db_name updating
UPDATE cmp_item SET title = 'Contract of employment 456', date_modification = '2015-06-16 09:14:37' WHERE id = 64297
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 15706 page no 10780 n bits 80 index `PRIMARY` of table `db_name`.`cmp_item` trx id 2009024 lock_mode X locks rec but not gap waiting
Record lock, heap no 14 PHYSICAL RECORD: n_fields 102; compact format; info bits 0
*** (2) TRANSACTION:
TRANSACTION 2009010, ACTIVE 0 sec starting index read
mysql tables in use 1, locked 1
12 lock struct(s), heap size 2936, 7 row lock(s), undo log entries 4
MySQL thread id 11124, OS thread handle 0x2aebdd723700, query id 1666536 172.31.26.135 db_name updating
UPDATE cmp_item SET title = 'Contract of employment 456', date_modification = '2015-06-16 09:14:38' WHERE id = 64297
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 15706 page no 10780 n bits 80 index `PRIMARY` of table `db_name`.`cmp_item` trx id 2009010 lock mode S locks rec but not gap
Record lock, heap no 14 PHYSICAL RECORD: n_fields 102; compact format; info bits 0
我们不明白为什么会出现这种僵局。
为什么会这样,我们怎样才能避免这种情况?
答案 0 :(得分:0)
死锁通常(总是?)需要在两个(或更多)线程中的每个线程中执行多个语句。据推测,您的两个更新前面都有一些其他语句,这些语句锁定了各种表中的各行。仔细查看整个D:>ssh -T git@git.company.com
Hi my_user! You've successfully authenticated, but GitHub does not provide shell access.
D:\>git clone git@git.company.com:myOrg/leaf.git
Cloning into 'leaf'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
... BEGIN
。把它们展示给我们。