Fix TimedJob execution time to allow job execution exactly when scheduled
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
TimedJobto run timed jobs when they are picked up at the exact same second they are due. - To keep the current behaviour, changed
ClearOldStatusesBackgroundJobandUserStatusAutomationto run in intervals of 1s.
TODO
- [ ] Confirm that it's ok to run the
ClearOldStatusesBackgroundJobandUserStatusAutomationevery second
Checklist
- Code is properly formatted
- Sign-off message is added to all commits
- [ ] Tests (unit, integration, api and/or acceptance) are included
- [ ] Screenshots before/after for front-end changes
- [ ] Documentation (manuals or wiki) has been updated or is not required
- [ ] Backports requested where applicable (ex: critical bugfixes)