Laravel Queues in Action is now available!

The problem behind "Integrity constraint violation: 1062 Duplicate entry for key 'failed_jobs_uuid_unique'"

Updated: Nov 9, 2020 — 1 min Read#quick-dip #queues

Here's the error you may get:

Integrity constraint violation: 1062 Duplicate entry '/3e2e41b5-2b0c-...' 
for key 'failed_jobs_uuid_unique' 
(SQL: insert intofailed_jobs (uuidconnection, queue, payload, 
exception, failed_at) values 
(3e2e41b5-..., redis, default,
 {"uuid":"3e2e41b5-...","displayName":"App\\Jobs\\TestJob"

It seems like Laravel is trying to log the same failed job with the same UUID multiple times. This may happen when two workers pick the same job and both executions fail. The first worker will be able to log the job successfully but the second worker will receive this error because an entry with the same UUID already exists.

Job duplication happens when the retry_after configuration value is not correctly set. The value should always be greater than your longest running job's timeout.

Hey! 👋 If you want to receive updates on what I'm up to, I host a newsletter on my website themsaid.com and would love to have you.

You can also follow me on Twitter, I regularly post about all things Laravel including my latest video tutorials and blog posts.

By Mohamed Said

Hello! I'm a full-stack web developer working at Laravel. In this publication, I share everything I know about Laravel's core, packages, and tools.

You can find me on Twitter and Github.

This site was built using Wink. Follow the RSS Feed.