Deal with deadlocks in MySQL
Posted: Wed 24 Jul 2013 20:07
Hi.
During some heavy update update operations made by a separate application, occasionally I get an Error "#40001 Deadlock found when trying to get lock; try restarting transaction". Having read MySQL tips to cope with this is to retry the transaction. My question is to know the best way to do this in Delphi. I'm doing this:
Doing this to every transaction, on both apps, is a valid way to deal with problem?
Any help is welcome. Thanks.
During some heavy update update operations made by a separate application, occasionally I get an Error "#40001 Deadlock found when trying to get lock; try restarting transaction". Having read MySQL tips to cope with this is to retry the transaction. My question is to know the best way to do this in Delphi. I'm doing this:
Code: Select all
transaction_completed_ok:= False;
repeat
try
my_db.StartTransaction;
(... do the inserts)
my_db.Commit;
transaction_completed_ok:= True;
except
my_db.Rollback;
Sleep(1000);
end;
until transaction_completed_ok;Any help is welcome. Thanks.