-
Notifications
You must be signed in to change notification settings - Fork 13
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
resumeOnRestart: Successful jobs never get restarted #54
Comments
If the
Please attach the actual code you tested. I will test that code. |
We also tried to test this scenario and I think the key point is that resumeOnRestart WON'T restart the job but the regular polling will do. Since the job finished correctly, resumeOnrestart won't catch that recurring job, but the regular polling will check that nextRun is lower than your current time and it will run and schedule it for every minute from that point in time (I think this is okay for most scenarios, but if you rely on your job having run exactly a certain number of times after a crash the implemented logic is not going to help you.) |
@christian-schwaderer @tcastelli Since we forked the existing agenda library code to create the resumeOnRestart feature, architectural issues emerged from |
@tcastelli What is the correct way to pull all the jobs from mongo and then resume them? I cannot simulate the
|
I am confused: should an already existing job with an repeat interval be restarted after {
_id: ObjectId('673da4da57ed2f3136b36c47'),
name: 'welcomeMessage',
type: 'single',
attempts: 0,
backoff: null,
data: {},
endDate: null,
nextRunAt: ISODate('2024-11-20T09:20:17.070Z'),
priority: 0,
repeatInterval: '5 seconds',
repeatTimezone: null,
shouldSaveResult: false,
skipDays: null,
startDate: null,
finishedCount: 2,
lastFinishedAt: ISODate('2024-11-20T08:59:16.062Z'),
runCount: 2
} If I re-run the sample code w/o the |
@jonaszuberbuehler I was able to solve this issue by switching to agenda. After server restart fetch all jobs using
for each job. I don't know why exactly the same thing doesn't work in pulsecron. |
@Beelink Thx, I am coming from Agenda. Your workaround was mentioned on many issues there. I was under the impression that Pulse would fix this (was also mentioned some times). For me it's counterintuitive: the jobs are already there, why should we call define again? |
@jonaszuberbuehler I totally agree, but I think this would be hard to implement because, on server restart, we need to find the callback provided. How? The old js context doesn't exist and there is no callback function anymore. |
@Beelink Valid point, which brings me back to what exactly is the |
@jonaszuberbuehler I chose pulse because of this flag and it never worked for me, I was trying to make it work a few times. Tried a few last versions from 1.6.3 to 1.6.6 Same with the |
Description
I have some concern regarding the
resumeOnRestart
option.Imagine a situation like this:
nextRunAt
is set to 9:01:00lastFinishedAt
is set to 9:00:00=> Server has missed the run at 9:01:00
=> I expect the job to rerun at 9:02:00
However, if my testing is right, it will never run again because of
in
resume-on-restart.ts
.The crucial part is
lastFinishedAt: { $exists: false }
.Pulse obviously "thinks": "Oh, this got successfully finished, so we do not have to do anything here".
Code example
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: