Issue -
I have failing workers because of Deadlock caused at JOBS table, while deleting entries of jobs.
This behaviour is frequent in occurrence, even over slight increase in traffic.
Need suggestions to avoid this Deadlock ?
Configuration -
Using Laravel queues with QUEUE_DRIVER=database
Supervisor as queue manger
DB is MySQL
Logs -
{"message":"SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock;
try restarting transaction (SQL: delete from `jobs` where `id` = 215520)","context":{"exception":{"class":"Illuminate\\Database\\QueryException","message":"SQLSTATE[40001]:
Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction
(SQL: delete from `jobs` where `id` =
215520)","code":40001,"file":"/home/aditya/Desktop/code/Chqbook-
api/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664","previous":
{"class":"PDOException","message":"SQLSTATE[40001]: Serialization failure: 1213 Deadlock found
when trying to get lock; try restarting
transaction","code":40001,"file":"/home/aditya/Desktop/code/Chqbook-
api/vendor/laravel/framework/src/Illuminate/Database/Connection.php:483"}}},"level":400,"level_n
ame":"ERROR","channel":"local","datetime":{"date":"2020-09-17
07:22:56.546154","timezone_type":3,"timezone":"Asia/Kolkata"},"extra":[]}
{"message":"SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction (SQL: insert into `jobs` (`queue`, `attempts`,