Mark Scout jobs as failed on timeout by default#1002
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1001, implementing the approach you suggested when closing it: no configuration, just
failOnTimeout = trueon the Scout jobs.Fixes #957.
The property is set on the
ConfiguresJobOptionstrait, which coversMakeSearchable,RemoveFromSearchand their*Uniquelysubclasses, and directly onMakeRangeSearchablesince that job does not use the trait.Why
When a Scout job exceeds its timeout on a queue with unlimited tries (
'tries' => 0, common in Horizon supervisor configs), the job is never marked as failed: the worker is killed, the job is released back onto the queue afterretry_afterand picked up again, indefinitely.horizon:forgetcannot help because the job never reachesfailed_jobs. I verified this end-to-end on a fresh Laravel 12 app with the database queue driver and a deliberately slowtoSearchableArray(): without this change the job stayed pending forever (six worker kills in 50 seconds,attemptsclimbing,failed_jobsempty); with this change the exact same scenario fails on the first timeout with aTimeoutExceededExceptioninfailed_jobsand the queue moves on.Behavioral change
Scout jobs now fail on the first timeout — including under the default 60 second worker timeout — instead of being released for another attempt. Since indexing is idempotent, a failed job can simply be retried with
queue:retry, and a job subclass can opt out by declaringpublic $failOnTimeout = false. One edge to be aware of: userland classes that useConfiguresJobOptionsdirectly and declare their own$failOnTimeoutproperty (or redeclare it with abooltype) will hit PHP's trait property conflict and need a small adjustment.Worth noting for completeness: a request that blocks forever inside a single I/O call is not interruptible by
pcntl_alarm, so client-level timeouts on the search engine remain necessary for that case — this change closes the queue-side gap where a fired timeout still never failed the job.