perf(cron): Delay (re)checking timed jobs#50768
Merged
ChristophWurst merged 1 commit intomasterfrom Mar 31, 2025
Merged
Conversation
Member
|
Tests might be nice for this, and it's not hard, the test infra for bg jobs is quite nice, imho: https://github.com/nextcloud/server/blob/master/tests/lib/BackgroundJob/JobListTest.php |
marcelklehr
reviewed
Feb 13, 2025
| // re-checking with every cron run. | ||
| // To avoid bugs that lead to jobs never executing again, the future timestamp is | ||
| // capped at two days. | ||
| $nextCheck = min($nextPossibleRun, $now + 48 * 3600); |
Member
There was a problem hiding this comment.
Do you have more details on why the 48 hours?
Member
Author
There was a problem hiding this comment.
I was thinking that someone might set a (dynamic) interval that is too high so that a job is never checked again. This gives the job a chance to recover.
For any jobs that run rarely (like every two weeks) and disabled apps, that would also help clear up the row earlier.
come-nc
approved these changes
Feb 13, 2025
Contributor
come-nc
left a comment
There was a problem hiding this comment.
Is it not possible to add a condition on lastrun+interval as part of the SQL query instead?
Member
Author
marcelklehr
reviewed
Mar 20, 2025
marcelklehr
approved these changes
Mar 28, 2025
3fa3611 to
8bc9498
Compare
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
8bc9498 to
2395526
Compare
nickvergessen
approved these changes
Mar 31, 2025
Member
Author
|
/backport to stable31 |
Merged
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.

Summary
Right now timed jobs are always loaded from the db and instantiated. Jobs with intervals higher than the cron interval are continuously loaded and checked,
\OCP\BackgroundJob\TimedJob::startprevents the actual execution.As an optimization we can preemptively check if a job is ready. Otherwise we park it for a later check.
How to test
TODO
Checklist