Skip to content

Integrity constraint violation on failed_jobs_uuid_unique #53230

@bytestream

Description

@bytestream

Laravel Version

11.28.1

PHP Version

8.3.12

Database Driver & Version

No response

Description

Calling Artisan::call('queue:work') multiple times results in the JobFailed event listener being bound multiple times. As a result of that logFailedJob() being called multiple times and when combined with the DatabaseUuidFailedJobProvider results in an exception being thrown:

Integrity constraint violation: 1062 Duplicate entry '414b6d4b-416e-4eb6-b5e5-9491c36d5146' for key 'failed_jobs.failed_jobs_uuid_unique'

There is a history of that exception and I suspect this is the reason.

Steps To Reproduce

    public function testArtisanCallQueueWork(): void
    {
        $event = \Illuminate\Support\Facades\Event::fake();

        $this->artisan('queue:work', ['--once' => true]);
        $this->artisan('queue:work', ['--once' => true]);

        $this->assertSame(1, count($event->dispatcher->getListeners(\Illuminate\Queue\Events\JobFailed::class)));
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions