Laravel Queues in Action (2nd edition) 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,

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 find this content useful, consider sponsoring me on GitHub.

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 former Laravel core team member & VP of Engineering at Foodics. 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.