0

I have a service that runs an update multi query update hits set hits = hits + 1 where id = x. I found out that running multiple instances of this service throws error Error 1213: Deadlock found when trying to get lock; try restarting transaction.

I don't know why this is happening or how to debug this. There's only one row being updated at a time which should not lead to deadlock. Does multi query acquire lock for all the columns at once? will the query below acquire lock for all x, y, z rows?

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;

0 Answers0