mysql“超过锁定等待超时”两个事务,索引不同的键

时间:2013-11-19 00:27:23

标签: mysql locking timeout wait

我有一组表需要使用特定键删除其记录并插入新记录。每个密钥使用一个不同的事务:

交易1:

DELETE FROM table1 WHERE id=1; -- many records
DELETE FROM table2 WHERE id=1; -- many records
INSERT INTO table1 VALUES (1,...),...; -- many records
INSERT INTO table2 VALUES (1,...),...; -- many records

交易2:

DELETE FROM table1 WHERE id=2; -- many records
DELETE FROM table2 WHERE id=2; -- many records
INSERT INTO table1 VALUES (2,...),...; -- many records
INSERT INTO table2 VALUES (2,...),...; -- many records

当两个事务同时运行时,我发现其中一个事务的锁定等待超时错误。两个表的id都被编入索引,因此它应该是基于行的锁定,为什么我仍然会收到此错误?

0 个答案:

没有答案