kue-scheduler icon indicating copy to clipboard operation
kue-scheduler copied to clipboard

Jobs are never processed in examples/every_unique.js

Open elyas-bhy opened this issue 8 years ago • 3 comments

elyas-bhy avatar Mar 29 '16 20:03 elyas-bhy

This seems to be a general issue, I was just investigating one of my jobs that seems to never run and its also a Unique / Every job, which I think is quite the common use case.

Also checked this in my local repository, but could not confirm it there. Job was processed. Although the log shows twice:

Processing job with id 6 at Wed Apr 27 2016 11:27:00 GMT+0200 (CEST)
Processing job with id 6 at Wed Apr 27 2016 11:27:01 GMT+0200 (CEST)
Processing job with id 6 at Wed Apr 27 2016 11:27:01 GMT+0200 (CEST)
Processing job with id 6 at Wed Apr 27 2016 11:27:03 GMT+0200 (CEST)
Processing job with id 6 at Wed Apr 27 2016 11:27:03 GMT+0200 (CEST)

KeKs0r avatar Apr 27 '16 09:04 KeKs0r

Unique re-uses the same job in the Unique / Every scenario, so if looking at the job details it will get pushed back to inactive status on its repeating schedule: https://github.com/lykmapipo/kue-scheduler/blob/master/index.js#L461

This does end up meaning you lose job run history, which from an operational standpoint is going to be suboptimal for a lot of users of kue-unique and kue-scheduler.

I believe kue-scheduler should at minimum only push a job back to inactive if it is in the complete or failed statuses, but a modification of the logic to update the unique:job hash if there is no active running job instead might make this behave in the way people are expecting?

gmcnaught avatar Jul 13 '16 16:07 gmcnaught

After digging in, the example app is not logging that the job ran because it is only triggering on job success, but unique would be firing the 'already scheduled' event instead of the 'job success'. I've sent in PR #41 to change the behavior to create a new job for every unique run, which has a few advantages to how kue-scheduler + kue-unique works with kue.

gmcnaught avatar Jul 18 '16 14:07 gmcnaught