-
Notifications
You must be signed in to change notification settings - Fork 68
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
job.cancel() with { dependents: false } fails #243
Comments
Hi, can you provide more information about how to reproduce this error? Specifically, what do you mean by:
Can you please share a working minimal reproduction (a working Meteor project that does nothing but create a JobCollection and then create a job or jobs that trigger this error). Just from your minimal description and the included stack trace I can't easily intuit the code that will reproduce this error. Thanks! |
Hi @vsivsi jus see this example: import { Meteor } from 'meteor/meteor';
import { _ } from 'lodash';
const PushJobs = new JobCollection('pushJobs');
// process 'removeOldJobs'
PushJobs.processJobs('removeOldJobs', { concurrency: 1, workTimeout: 20000 }, (job, cb) => {
const oldJobsTime = new Date((new Date()).getTime() - 30 * 1000); // 30 secs
const updateCountJobs = PushJobs.find({ type: 'updateNotificationCounts', status: { $in: PushJobs.jobStatusCancellable }, updated: { $lte: oldJobsTime, $exists: true } }, { fields: { _id: 1 }
}).fetch();
if (PushJobs.cancelJobs(_.map(updateCountJobs, '_id'), {
dependents: false // prevent checking for dependent jobs that don't exist anyway
})) {
PushJobs.removeJobs(_.map(updateCountJobs, '_id'));
}
job.done();
cb();
});
// process 'updateNotificationCounts' dummy job
PushJobs.processJobs('updateNotificationCounts', { concurrency: 1, workTimeout: 20000 }, (job, cb) => {
// do nothing
job.done();
cb();
});
Meteor.startup(() => {
// start the job that removes the old jobs
new Job(PushJobs, 'removeOldJobs', {})
.priority('normal')
.repeat({
schedule: PushJobs.later.parse.recur().every().minute()
})
.save({ cancelRepeats: true });
// fill the DB with dummy jobs to be removed
Meteor.setInterval(() => {
new Job(PushJobs, 'updateNotificationCounts', {})
.priority('normal')
.save();
}, 5000);
});
This is what I mean by By doing that, I can reproduce the error easily, my jobs don't have any dependencies and |
Okay, thanks for that. I see the bug, weird that no one has ever encountered this before. Probably because cancelling dependent jobs is both the default behavior, and the normally correct thing to do. (Why would you want dependent jobs to remain waiting forever after their antecedent is cancelled? ) Anyway, I'll fix this and it will be in the next release whenever that is. In the meantime, just don't do this (set Thanks for the bug report! |
Fixed on |
Thanks for the fix! We were creating and also cancelling many jobs at once and we detected a very high CPU usage at our mongo DB. |
Oh, that's a good tip! Thx. |
I am running
job.cancel()
inside a running job. Getting this Mongo exception when trying to cancel a job with thedependents
option set tofalse
:The text was updated successfully, but these errors were encountered: