Add optional stale-timeout to QueuedJobsTable::isQueued()#503
Closed
dereuromark wants to merge 1 commit into
Closed
Add optional stale-timeout to QueuedJobsTable::isQueued()#503dereuromark wants to merge 1 commit into
dereuromark wants to merge 1 commit into
Conversation
isQueued() counts any row with `completed IS NULL`. A job that a worker fetched and then died on (OOM, timeout, kill) without marking it completed or failed stays `completed IS NULL` forever, so callers that gate on isQueued() — notably a non-concurrent scheduler deciding whether to dispatch the next run — can wedge permanently behind a job that will never make progress. Adds an optional `$staleTimeout` (seconds) parameter: a row fetched longer ago than the timeout and still not completed is presumed abandoned and excluded. Not-yet-fetched rows, and rows fetched within the window, still count. The default `null` preserves the original behaviour, so this is fully backward compatible.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #503 +/- ##
============================================
+ Coverage 78.32% 78.36% +0.03%
- Complexity 978 979 +1
============================================
Files 45 45
Lines 3313 3318 +5
============================================
+ Hits 2595 2600 +5
Misses 718 718 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced May 28, 2026
Closed
Owner
Author
|
Superseded by #504. The stale-fetch discriminator here was wrong: a job with retries remaining is one the queue itself re-runs, so the scheduler would re-dispatch a duplicate and pile up failed rows. #504 instead persists the terminal 'aborted' verdict the queue already computes, which fixes the wedge without that side effect. |
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.
Problem
QueuedJobsTable::isQueued()counts any row withcompleted IS NULL. A job that a worker fetched and then died on (OOM, PHP timeout, container kill) without ever marking the row completed or failed stayscompleted IS NULLindefinitely.Callers that gate on
isQueued()then wedge behind that ghost row. The concrete case: a non-concurrent QueueScheduler row (allow_concurrent = false) checksisQueued($reference, $task)before dispatching the next run. Once a prior job is stuck "running" (fetched, never completed), every subsequent dispatch — cron and manual "Run" alike — is held back forever, even though nothing is actually executing.Change
Adds an optional
$staleTimeout(seconds) parameter toisQueued():When provided, a row that was
fetchedlonger ago than the timeout and is still not completed is presumed abandoned and excluded. Rows not yet fetched, and rows fetched within the window, still count.$staleTimeoutdefaults tonull, which preserves the exact original behaviour — fully backward compatible. ExistingtestIsQueued()is untouched and still passes.Tests
Added
testIsQueuedStaleTimeout()andtestIsQueuedStaleTimeoutIgnoresUnfetched()covering the fetched-but-abandoned, still-within-window, and never-fetched cases. FullQueuedJobsTableTestgreen; phpcs and phpstan clean on the changed file.