agenda / agenda

Lightweight job scheduling for Node.js
http://agendajs.com
Other
9.39k stars 800 forks source link

agenda.now() queued jobs stop being processed after a few days of running #345

Open netslayer opened 8 years ago

netslayer commented 8 years ago

I have an agenda defined job that issues off n number of jobs with agenda.now() with specific job parameters. Prior to running this job it clears old enqueued jobs with agenda.cancel(). Each job does a node request() and stores data in a mongo collection when run.

After running for a few days the jobs enqueued with now() stop being run and just stay queued. I have concurrency set to 5 on each, running a single agenda instance and my requests have timeouts on.

Any ideas on what I am missing that could cause it to stop actually running now() jobs?

setup:

agenda job: "enqueue work" first clears out old "work" jobs using agenda.cancel(), and then finds new ids to process and queues agenda.now("work") with each id.

agenda job: "work" actually takes the id and does node requests() and saves data back into mongo using mongoose. that's it

TimJohns commented 7 years ago

Any resolution? We're seeing the same thing and are considering instrumenting processJobs() to see if we can figure it out.

netslayer commented 7 years ago

After we revised the code with async lib and made sure only one job.done() was being called it started working smoothly. This led to the patch to fix concurrency with multiple done() calls. Clearing jobs collection and bouncing node does seem to alleviate any stuck jobs but this rarely happens now for us.