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

Handle failures in pending jobs #18

Closed
dalelane opened this issue Jun 26, 2018 · 2 comments
Closed

Handle failures in pending jobs #18

dalelane opened this issue Jun 26, 2018 · 2 comments

Comments

@dalelane
Copy link
Member

At the moment, all pending job processing is stopped when one fails.

We could improve on this, so that other jobs can still be attempted if there is a single blip.

@dalelane dalelane reopened this Jun 26, 2018
@dalelane
Copy link
Member Author

The code lives here:

try {
const start = new Date();
nextJob = await db.getNextPendingJob();
while (nextJob) {
await processor.processJob(nextJob);
await db.deletePendingJob(nextJob);
nextJob = await db.getNextPendingJob();
}
const end = new Date();
const durationMs = end.getTime() - start.getTime();
log.info({ durationMs }, 'No pending jobs remain');
if (durationMs > constants.THREE_HOURS) {
notifications.notify('Processing pending jobs took longer than THREE HOURS');
}
}
catch (err) {
log.error({ err, nextJob }, 'Pending job failure');
notifications.notify('Critical failure in processing pending jobs: ' + err.message);
if (nextJob) {
db.recordUnsuccessfulPendingJobExecution(nextJob);
}
}

The try...catch is laid out so that if one task fails, it throws us out of the while (nextJob) loop.

@dalelane
Copy link
Member Author

Closing - as not worth the effort. In over a year, it's never actually failed, so investing in handling failure seems like a waste of time. Worst case scenario, if there is a failure, I can manually remove the failing job to unblock the rest - and then revisit whether it's worth automating it.

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

No branches or pull requests

1 participant