lykmapipo / kue-scheduler

A job scheduler utility for kue, backed by redis and built for node.js
246 stars 47 forks source link

kue-scheduler does not re-schedule unique job if worker dies uncleanly #82

Open gmcnaught opened 7 years ago

gmcnaught commented 7 years ago

I believe this is due to a change I introduced:

If a unique job is 'active' and the worker that is processing the job becomes unavailable and never calls done(), and doesn't respond to the ttl timeout, the job will be stuck in 'active', and therefore never gets re-scheduled due to:

https://github.com/lykmapipo/kue-scheduler/blob/master/index.js#L56

    var isCompletedOrFailedJob =
      (job.state() === 'complete' ||
        job.state() === 'failed');

    if (isCompletedOrFailedJob) {

I will submit a pull request to also check if the last_updated value is older than the job ttl and schedule the next job - this way they do not end up stale.

The only reservation I have about this method is that in a situation where the worker is just unable to talk to redis, it may complete the work twice.

lykmapipo commented 7 years ago

appreciated

TangMonk commented 7 years ago

same problem

bilby91 commented 6 years ago

I think we are having a similar issue here. After we received a timeout error from redis, the unique scheduled job never triggered again.

Jageen commented 6 years ago

I am having same problem and planning to do this

if Job is timeout Create new job based on the job data. Delete old job.

Is there any logical error on above flow ?