Commit 4e20c7a
committed
fix: avoid duplicate ModelNotFoundException logs on orphaned queued jobs
When a queued job's serialized model is deleted between dispatch and
worker pickup, Laravel's CallQueuedHandler catches the unserialize
ModelNotFoundException via handleModelNotFound. Without
deleteWhenMissingModels, it then routes the job to fail(), which
re-deserializes the payload and throws ModelNotFoundException a second
time — this one is not caught and gets logged.
Set deleteWhenMissingModels = true on AbstractJob so the handler
delete()s the job (already off the queue, lock already released) instead
of going through the noisy fail() path. All current AbstractJob
subclasses (notification fan-out, mail sends, search index, package
manager, gdpr export, etc.) are no-ops when their subject model is
missing — there's no useful retry path.
Subclasses that genuinely want to be retried/failed on missing models
can override with `public bool $deleteWhenMissingModels = false;`.
Fixes #46151 parent d6dc7c4 commit 4e20c7a
1 file changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
22 | 34 | | |
0 commit comments