Commit 77da2bc
committed
Add optional stale-timeout to QueuedJobsTable::isQueued()
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.1 parent 25b2c08 commit 77da2bc
2 files changed
Lines changed: 65 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
279 | 294 | | |
280 | 295 | | |
| 296 | + | |
| 297 | + | |
281 | 298 | | |
282 | 299 | | |
283 | 300 | | |
284 | 301 | | |
285 | 302 | | |
286 | | - | |
| 303 | + | |
287 | 304 | | |
288 | 305 | | |
289 | 306 | | |
| |||
295 | 312 | | |
296 | 313 | | |
297 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
298 | 321 | | |
299 | 322 | | |
300 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
834 | 834 | | |
835 | 835 | | |
836 | 836 | | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
837 | 878 | | |
838 | 879 | | |
839 | 880 | | |
| |||
0 commit comments