Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the resumeOnRestart function to handle correctl the recurring jobs + do not run finished non-recurrent jobs on restart + add unit tests #62

Merged
merged 4 commits into from
Nov 19, 2024

Conversation

b0dea
Copy link
Collaborator

@b0dea b0dea commented Nov 19, 2024

Hi,

This PR hopes to solve some/all problems that have been flagged under these issues

So, I'm proposing some changes to improve how resumeOnRestart works, ensure we’re handling all types of jobs correctly, and fix issues around rescheduling non-recurring jobs that shouldn’t be run again (on restart).

What’s Changed?

  1. Improved resumeOnRestart

    • Non-recurring jobs:
      • Added a strong(er) check when searching for non-recurring jobs to search for both non-existent lastFinishedAt but also cover the case in which it is null
    • Recurring jobs:
      • Add proper search for the unfinished recurrent jobs and then reschedule them using the computeNextRunAt function.
  2. Adjusted Job Model nextRunAt default - If a non-recurring jobs is completed (lastFinishedAt exists), we should preserve the set nextRunAt (if it was set explicitly) and we should do not default it to new Date() (which triggers a re-run). For the recurrent jobs, we can keep what has been done before (either nextRunAt or new Date()).

  3. Added Test Cases to check as much as we can if resumeOnRestart works properly

Let me know if you spot any edge cases or mistakes I need to fix.

@code-xhyun code-xhyun assigned code-xhyun and b0dea and unassigned code-xhyun Nov 19, 2024
@code-xhyun code-xhyun self-requested a review November 19, 2024 06:50
@code-xhyun code-xhyun merged commit c8e87f0 into pulsecron:main Nov 19, 2024
1 check passed
@code-xhyun code-xhyun changed the title Fix the resumeOnRestart function to handle correctl the recurring jobs + do not run finished non-recurrent jobs on restart + add unit tests fix: the resumeOnRestart function to handle correctl the recurring jobs + do not run finished non-recurrent jobs on restart + add unit tests Nov 19, 2024
@b0dea b0dea deleted the fix-resumeonrestart branch November 19, 2024 07:10
@code-xhyun
Copy link
Contributor

🎉 This PR is included in version 1.6.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants