laravel / horizon

Dashboard and code-driven configuration for Laravel queues.
https://laravel.com/docs/horizon
MIT License
3.87k stars 657 forks source link

Duplicate UUID key entries for failed jobs #953

Closed lasselehtinen closed 3 years ago

lasselehtinen commented 3 years ago

Description:

I swapped to the UUID for failed jobs, but now I am quite often I am getting duplicate key entries for failed jobs. I am running several separate workers that use one main redis server if that makes any difference.

Illuminate\Database\QueryException SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'cfce569e-e2a1-4105-b16d-3860d59abcca' for key 'failed_jobs.failed_jobs_uuid_unique' (SQL: insert intofailed_jobs(uuid,connection,queue,payload,exception,failed_at) values ...

Config should be OK:

Psy Shell v0.10.4 (PHP 7.4.13 — cli) by Justin Hileman
>>> config('queue.failed');
=> [
     "driver" => "database-uuids",
     "database" => "mysql",
     "table" => "failed_jobs",
   ]
>>> 
paras-malhotra commented 3 years ago

@lasselehtinen is your retry_after set to be greater than your queue timeout (default: 60 seconds)? See https://laravel.com/docs/8.x/queues#worker-timeouts and https://divinglaravel.com/integrity-constraint-violation-duplicate-entry-for-key-failed_jobs_uuid_unique

driesvints commented 3 years ago

Closing this issue because it's inactive, already solved, old or not relevant anymore. Feel free to reply if you're still experiencing this issue and we'll re-open this issue.