我有一组表需要使用特定键删除其记录并插入新记录。每个密钥使用一个不同的事务:
交易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都被编入索引,因此它应该是基于行的锁定,为什么我仍然会收到此错误?