Skip to content

Conversation

@salmart-dev
Copy link
Contributor

@salmart-dev salmart-dev commented Jun 10, 2025

Summary

This PR is a follow-up to address issues discovered while investigating issue #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.

Checklist

@salmart-dev salmart-dev self-assigned this Jun 10, 2025
@salmart-dev salmart-dev added the 3. to review Waiting for reviews label Jun 10, 2025
@salmart-dev salmart-dev marked this pull request as ready for review June 10, 2025 10:51
@salmart-dev salmart-dev requested a review from a team as a code owner June 10, 2025 10:51
@salmart-dev salmart-dev requested review from ArtificialOwl, come-nc and skjnldsv and removed request for a team June 10, 2025 10:51
@come-nc come-nc added this to the Nextcloud 32 milestone Jun 10, 2025
@salmart-dev
Copy link
Contributor Author

@come-nc as you suggested, I added some code to remove the job if it runs but the user does not exist any longer and a test for this case.

@salmart-dev salmart-dev force-pushed the fix/timedjob-execution-time branch 2 times, most recently from fa0a2ec to 2b2d3d9 Compare June 18, 2025 10:16
@salmart-dev
Copy link
Contributor Author

/backport to stable30

@salmart-dev
Copy link
Contributor Author

/backport to stable31

@salmart-dev salmart-dev force-pushed the fix/timedjob-execution-time branch from 2b2d3d9 to e95fb81 Compare June 20, 2025 16:36
@github-actions
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@salmart-dev salmart-dev force-pushed the fix/timedjob-execution-time branch 2 times, most recently from b7f574b to 5563503 Compare July 1, 2025 11:29
These jobs that were setting their interval to 0 were not really running
at every run of cron.php if the run was in the same second. To keep the
same behaior, I am updating those intervals to 1 second.

Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
@salmart-dev salmart-dev force-pushed the fix/timedjob-execution-time branch from 5563503 to 289b7ab Compare July 1, 2025 13:15
@nickvergessen nickvergessen merged commit d67396f into master Jul 3, 2025
193 of 197 checks passed
@nickvergessen nickvergessen deleted the fix/timedjob-execution-time branch July 3, 2025 12:16
@salmart-dev salmart-dev added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jul 22, 2025
@skjnldsv skjnldsv mentioned this pull request Aug 19, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish bug feedback-requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants