#deadlock on jobs table

9 messages · Page 1 of 1 (latest)

marsh lichen
#

im getting deadlock errors

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (Connection: mysql, SQL: select * from `jobs` where `queue` = default and ((`reserved_at` is null and `available_at` <= 1682060405) or (`reserved_at` <= 1682060315)) order by `id` asc limit 1 for update)

it is always on jobs table and it is seemingly random it doesnt happen every hour it happens few times per day and every day in different hours

i dont even know where to start debugging it clearly indicates that something is wrong with queue but i dont know what there is only 1 job which is processed hourly and that job is to take few models and send them to meilisearch with scout and since it is not always failing (it fails less than half of hours daily sometimes as low as 1 or 2) so also its pretty clear that the job itself is not necessarily cause of issue

#

i just checked logs (we added another job recently which runs every minute) to see if that also fails and yes it also fails in random intervals but obviously since that one is every minute now it also happens at times like 11:05 11:07 etc

#

i dont know if its important but there are multiple workers

hushed elk
#

are you using the database as the driver? I believe you will need to switch the driver

marsh lichen
#

oh 🥴 i will try that

hexed shore
marsh lichen
#

yes

hexed shore
#

Thanks for the response, I am getting similar issue after updating Laravel version to 11.
I am getting this error.
[2025-02-06 11:57:54] production.ERROR: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (Connection: mysql, SQL: insert ignore into cache (key, value, expiration) values (bdcab399eef7b9acf9b3e93ff820:timer, i:1738843134;, 1738843134)) {"exception":"[object] (Illuminate\Database\QueryException(code: 40001): SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (Connection: mysql, SQL: insert ignore into cache (key, value, expiration) values (bdcab399eef7b9acf9b3e93ff820:timer, i:1738843134;, 1738843134)) at /vendor/laravel/framework/src/Illuminate/Database/Connection.php:825)