我不明白两个重复查询如何使用主键删除单个表的单个行可能会死锁。谁能解释一下?
在我看来,其中一项交易应该已获得锁定,而另一笔交易将不得不等待。
这是带有查询的死锁报告:
Fri Jun 01 2012 13:50:23
*** (1) TRANSACTION:
TRANSACTION 3 1439005348, ACTIVE 0 sec, process no 22419, OS thread id 1166235968 starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 368
MySQL thread id 125597624, query id 3426379709 node3-int 10.5.1.119 application-devel updating
DELETE FROM `SessData` WHERE `SessKey` = '87EDF1479A275557AC8280DCA78AB886'
AND `Name` = 'CurrentRequestURL'
*** (2) TRANSACTION:
TRANSACTION 3 1439005340, ACTIVE 0 sec, process no 22419, OS thread id 1234073920 starting index read, thread declared inside InnoDB 0
mysql tables in use 1, locked 1
3 lock struct(s), heap size 1216
MySQL thread id 125597622, query id 3426379705 node2-int 10.5.1.118 application-devel updating
DELETE FROM `SessData` WHERE `SessKey` = '87EDF1479A275557AC8280DCA78AB886'
AND `Name` = 'CurrentRequestURL'
*** WE ROLL BACK TRANSACTION (2)
这是表的架构:
CREATE TABLE `application`.`SessData` (
`SessKey` varchar(255) NOT NULL default '',
`Name` varchar(255) NOT NULL default '',
`Value` varchar(255) default NULL,
PRIMARY KEY (`SessKey`,`Name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
其他一些细节:
MySQL version: 4.1.21
Isolation level: REPEATABLE-READ
Character set on the the above columns: latin1