Laravel Version
13.5.0
PHP Version
8.5
Database Driver & Version
No response
Description
Changes to ShouldBeUniqueUntilProcessing in #59567 are causing what appears to be lost jobs in 13.5.0.
Scenario
I have a production Laravel application that uses jobs heavily. It's been working properly for >1 year, through many framework upgrades, but started failing after upgrading to 13.5.0 with what appears to be lost jobs.
I have a model with a stale_since timestamp. When something changes the model, I set the model's stale_since to the current date and dispatch a job, which performs some calculations and clears stale_since. The job has ShouldBeUniqueUntilProcessing and WithoutOverlapping middleware, so there should be at most 2 instances of the job for a given model at a given point in time - 0..1 pending and 0..1 processing. A job dispatched after setting stale_since may ultimately not be run - it may be dropped by ShouldBeUniqueUntilProcessing because another job is pending for that model - but in that case the pending job should ultimately clear the model's stale_since.
(I'm aware there are at least 2 logical race conditions in what I'm describing. This is an oversimplification. All that matters is that the the final stale_since that gets set should be cleared by the final job that gets processed, even if that job was already pending when the final stale_since was set. 😄)
In 13.4.0 and earlier, this logic held.
However, after upgrading to 13.5.0, I've suddenly started seeing models with stale_since set long after they should have been cleared, with no jobs pending, and with no exceptions and no failed jobs logged. It seems the jobs were "lost" in the framework.
Downgrading to 13.4.0 immediately resolved the issue.
Patching 13.5.0 to revert #59567 also resolved the issue.
Steps To Reproduce
I've created a self-contained repro that sets up this exact scenario as simply as I can. It passes with 13.4.0, fails with 13.5.0, and passes with 13.5.0 patched to revert #59567:
https://github.com/nmbrcolin/repro-stale
Laravel Version
13.5.0
PHP Version
8.5
Database Driver & Version
No response
Description
Changes to
ShouldBeUniqueUntilProcessingin #59567 are causing what appears to be lost jobs in 13.5.0.Scenario
I have a production Laravel application that uses jobs heavily. It's been working properly for >1 year, through many framework upgrades, but started failing after upgrading to 13.5.0 with what appears to be lost jobs.
I have a model with a
stale_sincetimestamp. When something changes the model, I set the model'sstale_sinceto the current date and dispatch a job, which performs some calculations and clearsstale_since. The job hasShouldBeUniqueUntilProcessingandWithoutOverlappingmiddleware, so there should be at most 2 instances of the job for a given model at a given point in time - 0..1 pending and 0..1 processing. A job dispatched after settingstale_sincemay ultimately not be run - it may be dropped byShouldBeUniqueUntilProcessingbecause another job is pending for that model - but in that case the pending job should ultimately clear the model'sstale_since.(I'm aware there are at least 2 logical race conditions in what I'm describing. This is an oversimplification. All that matters is that the the final
stale_sincethat gets set should be cleared by the final job that gets processed, even if that job was already pending when the finalstale_sincewas set. 😄)In 13.4.0 and earlier, this logic held.
However, after upgrading to 13.5.0, I've suddenly started seeing models with
stale_sinceset long after they should have been cleared, with no jobs pending, and with no exceptions and no failed jobs logged. It seems the jobs were "lost" in the framework.Downgrading to 13.4.0 immediately resolved the issue.
Patching 13.5.0 to revert #59567 also resolved the issue.
Steps To Reproduce
I've created a self-contained repro that sets up this exact scenario as simply as I can. It passes with 13.4.0, fails with 13.5.0, and passes with 13.5.0 patched to revert #59567:
https://github.com/nmbrcolin/repro-stale