bull repeatable jobs left in Redis

2.4k views Asked by At

I started using the repeatable jobs in bull and everything seems to be working well for me. However, I noticed that each iteration leaves a job in Redis:

  1. "test:foo:repeat:7a140b0cf5b3ee29cb164b7c9cc03bc3:1619132310000"
  2. "test:foo:repeat:7a140b0cf5b3ee29cb164b7c9cc03bc3:1619132280000"
  3. "test:foo:repeat:7a140b0cf5b3ee29cb164b7c9cc03bc3:1619132360000"

and the list keeps growing. I tried to do a job.remove() within the process function, but it threw an error... can't remove repeatable jobs I guess. I'm assuming these will eventually be cleaned up by Redis, but is there something more proactive I can do to keep Redis clean?

2

There are 2 answers

1
ticktock On BEST ANSWER

Needed to add the 'removeOnComplete' value to the jobOptions.

0
Paul Deng On

You can also clean the completed jobs by

queue.clean(0, 'completed');

Refer to https://github.com/OptimalBits/bull/issues/709#issuecomment-344561983