server icon indicating copy to clipboard operation
server copied to clipboard

Fix TimedJob execution time to allow job execution exactly when scheduled

Open salmart-dev opened this issue 7 months ago • 0 comments

Summary

This PR is a follow-up to address issues discovered while investigating issue https://github.com/nextcloud/server/issues/49584

While investigating the issue above, I noticed that when running occ background-job:worker the same job can be seen running several times, with each run in rapid succession after the other. The problem comes from an inconsistency in the comparison of timestamps between the logic that picks up jobs to execute and the logic inside TimedJob::start.

The jobs appearing in rapid succession would appear as ran, but because of the logic they would not really run until the next second. For the same reason, jobs that apparently ran when executing cron.php in the same second they were scheduled, were actually not run but silently skipped until the next run.

For the reasons above, this PR:

  • Changes TimedJob to run timed jobs when they are picked up at the exact same second they are due.
  • To keep the current behaviour, changed ClearOldStatusesBackgroundJob and UserStatusAutomation to run in intervals of 1s.

TODO

  • [ ] Confirm that it's ok to run the ClearOldStatusesBackgroundJob and UserStatusAutomation every second

Checklist

salmart-dev avatar Jun 10 '25 09:06 salmart-dev