0

我有一个运行更新多查询的服务update hits set hits = hits + 1 where id = x。我发现运行此服务的多个实例会引发错误Error 1213: Deadlock found when trying to get lock; try restarting transaction

我不知道为什么会发生这种情况或如何调试它。一次只更新一行,不会导致死锁。多查询是否一次获得所有列的锁定?下面的查询会为所有 x、y、z 行获取锁吗?

update hits set hits = hits + 1 where id = x; update hits set hits = hits + 1 where id = y; update hits set hits = hits + 1 where id = z;
4

0 回答 0