Skip to content

[13.x] Release the unique lock when dispatching a scheduled job fails - #62083

Merged
taylorotwell merged 2 commits into
laravel:13.xfrom
sumaiazaman:13.x-release-unique-lock-when-dispatching-scheduled-job-fails
Oct 18, 2026
Merged

taylorotwell merged 2 commits into
laravel:13.xfrom
sumaiazaman:13.x-release-unique-lock-when-dispatching-scheduled-job-fails

Conversation

@sumaiazaman

Copy link
Copy Markdown
Contributor

A unique job scheduled with Schedule::job() keeps its unique lock when pushing it to the queue fails. Once the queue is reachable again, the scheduler keeps skipping the job because the lock from the failed run is still held, and with the default uniqueFor of 0 it never expires:

Schedule::job(new SyncInventory)->everyFiveMinutes(); // SyncInventory implements ShouldBeUnique

// 10:00  push fails, Redis is unreachable
// 10:05  skipped, the lock is still held
// 10:10  skipped

Schedule::dispatchUniqueJobToQueue() acquires the lock and then dispatches the job, but nothing releases the lock if the dispatch throws. This is the same issue #62010 fixed for dispatch() and #62045 fixed for queued listeners, in the remaining place that acquires the lock itself.

This releases the lock when dispatching throws and rethrows the exception, the same way as those two.

@taylorotwell
taylorotwell merged commit 3bbfbac into laravel:13.x Oct 18, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants