Serialization failure: 1213 Deadlock found when trying to get lock
Getting Deadlock in jobs table , I'm using supervisor , If i use Redis this will be solved ,But if there is any solutions for mysql Please let me know.
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: select * from `jobs` where `queue` = default and ((`reserved_at` is null and `available_at` <= 1642088282) or (`reserved_at` <= 1642088192)) order by `id` asc limit 1 for update) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 40001): SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: select * from `jobs` where `queue` = default and ((`reserved_at` is null and `available_at` <= 1642088282) or (`reserved_at` <= 1642088192)) order by `id` asc limit 1 for update) at /var/www/utllv/data/www/utllv.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669)
Without seeing any code it's hard to help you but deadlocks occur when more than one process is trying to do something with the same record, or when the database calls are extremely frequent and you have more than one index on the table. The indexes lock each other if they are updated very frequently.
So tell us what you are trying to do and show some code and we might be able to give you some advice on how to solve the issue,
@Tray2 Thanks for the reply , Actually it's an API call and it's inserting data fetched from API , I think the first process takes long so the next one Also picking the same job ,please let me know which part of the code you need to see i'll post