bullmq icon indicating copy to clipboard operation
bullmq copied to clipboard

[Bug]: Removing repeatable job, does not remove current delayed job

Open i-rebel-aj opened this issue 2 years ago • 11 comments

Version

4.9.0

Platform

NodeJS

What happened?

I created a repeatable job by using the following method.

await myQueue.add(`${some_random_id}`,
{...data},
{ repeatJobKey: `${some_random_id}`, repeat: { every: 3480000 } });

I remove the repeatable job using method

 const job = await myQueue.removeRepeatableByKey(
            that_random_id
        );

It successfully deletes from the repeatable job list. which I attain from the method getRepeatableJobs(), However not from bull-ui.

The current delayed job is kept in the platform, only after its execution I see no further jobs being spawned.

This seems to be happening post-version 4.7.0, I was not able to backtrack breaking version.

How to reproduce.

Platform

OS: Ubuntu 22.04.3 LTS Node.js : v18.17.1 Redis: 7.2.0

The Code To add to queue

await myQueue.add(`${some_random_id}`,
{...data},
{ repeatJobKey: `${some_random_id}`, repeat: { every: 3480000 } });

The code to remove to queue

  console.log("before ----------------->", (await myQueue.getRepeatableJobs()).length)
        const removed = await myQueue.removeRepeatableByKey(
            that_id
        );
        console.log("remove ------>", removed);
        console.log("after ----------------->", (await myQueue.getRepeatableJobs()).length)

Output on stdout for removal

image

Bull UI image

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

i-rebel-aj avatar Sep 06 '23 13:09 i-rebel-aj

what does myQueue.getDelayed() return after removing the repeatable job?

manast avatar Sep 07 '23 09:09 manast

hi @i-rebel-aj, repeatJobKey is not supposed to be set by users, this is generated by bullmq and it's considered as an internal property https://api.docs.bullmq.io/interfaces/v4.BaseJobOptions.html#repeatJobKey

roggervalf avatar Nov 01 '23 04:11 roggervalf

image

I had the same problem, when I deleted the repeatable task, it returned to normal, but the most recent one still got executed and I could see the task on the UI panel image

It will not be actually removed until the latest repeatable task is executed.

FeiFanLiang avatar Feb 29 '24 08:02 FeiFanLiang

bull version 4.10.4

FeiFanLiang avatar Feb 29 '24 08:02 FeiFanLiang

what does myQueue.getDelayed() return after removing the repeatable job?

Using getDelayed still returns the most recent repeatable task. I need to manually remove the task before I can actually remove the repeatable task. image

FeiFanLiang avatar Feb 29 '24 09:02 FeiFanLiang

Experiencing the same behaviour

EinfachHans avatar Apr 11 '24 11:04 EinfachHans

@manast , @roggervalf, this is still happening with v5.8.3.

I also tried applying the patch from https://github.com/taskforcesh/bullmq/pull/2617, but the issue is still there.

What are the next steps to resolve this? Do you guys need a minimal reproducible example here?

dalechyn avatar Jun 29 '24 13:06 dalechyn

hi @dalechyn, if you can provide a minimal test case where we can reproduce it, we have some tests that cover removal of delayed jobs from repeatables https://github.com/taskforcesh/bullmq/blob/master/tests%2Ftest_repeat.ts#L1187

roggervalf avatar Jun 30 '24 03:06 roggervalf

for me, if I use key field in repeat options, it would result in this behavior, removing key field will solve this issue. before:

const repeat: RepeatOptions =  {every: 10_000, key: 'any-random-key'}

after:

const repeat: RepeatOptions =  {every: 10_000}

can't say the same for cron pattern because I didn't use it.

Note:

  • bullmq version v5.9.0.
  • redis: dragonflydb

doaortu avatar Jul 16 '24 06:07 doaortu

pls folks try v5.10.0 where repeatable jobs were refactored and let us know

roggervalf avatar Jul 16 '24 12:07 roggervalf

@roggervalf I can confirm that this works with the new repeat job format that was introduced in 5.10.x 👍🏼

EinfachHans avatar Jul 26 '24 10:07 EinfachHans