Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean all delayed jobs can finish on inconsistent state #294

Open
Zikoel opened this issue Jun 7, 2021 · 10 comments
Open

clean all delayed jobs can finish on inconsistent state #294

Zikoel opened this issue Jun 7, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@Zikoel
Copy link

Zikoel commented Jun 7, 2021

Hi,

Maybe I'm wrong but I notice that if you clean all delayed jobs this doesn't remove repeatable jobs. This is not an expected behavior because if you ask to bull for repeatable jobs it returns your jobs but that repeatable will never run again because the delayed counterparts are deleted. I think this is an inconsistent state for bull,
I'm not sure here what is the best things to to, maybe one of these:

  • Create a new tab for repeatable jobs and remove from the delayed the repeatable counterpart, threat all repeatable at the same manner
  • When delete delayed job if there is a repeatable counterpart remove that too (maybe notify the user that some delayed job are chained to a repeatable job)

This make sense for you or just I don't understand well what happen inside bull ?

@felixmosh
Copy link
Owner

I'm not sure regarding that, but sounds like bull should handle this... This lib calls bulls queue.clean, if it doesn't remove all the parts it is bull's bug.

Wdyt?

@felixmosh
Copy link
Owner

Ping?

@mdgozza
Copy link

mdgozza commented Aug 13, 2021

Hi @felixmosh

I ran into this issue as well. It appears the only proper way to remove repeatable jobs is to use the removeRepeatable methods
https://github.com/OptimalBits/bull/blob/master/REFERENCE.md#queueremoverepeatable

I simply wrote something like this to fix my inconsistent state:

// remove all repeatable jobs
  const repeatableJobs = await queue.jobQueue.getRepeatableJobs();
  await Promise.all(
    repeatableJobs.map((j) => queue.jobQueue.removeRepeatableByKey(j.key))
  );

Also, on a side note: I think distinguishing delayed from repeating tasks would be kinda neat.

In the meantime I enabled readOnlyMode for that queue until the delete methods can be trusted 👌

@felixmosh
Copy link
Owner

Thank you for the explanation, I'll review a possible solution soon 🙏🏼

@stale
Copy link

stale bot commented Jan 19, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jan 19, 2022
@felixmosh felixmosh added bug Something isn't working and removed wontfix This will not be worked on labels Jan 19, 2022
@ThomasKoscheck
Copy link

Hey,
are there any updates on this?
This bug still exists

@felixmosh
Copy link
Owner

Hi @ThomasKoscheck this bug totally slip my eyes, can you explain how can I reproduce it?

@ThomasKoscheck
Copy link

ThomasKoscheck commented Sep 9, 2023

Sure, the reproduction is quite easy

1. Create a MQ

const myQueue = new Queue("myQueue", {connection: redisOptions});

2. Create a repeatable job in the queue

await BullMq.addRepeatableJobToQueue(
        'myQueue',
        'jobname',
        data,
       1000 * 60, // just as example
        'myId'
    );

3. Delete from bullboard

Navigate to bullboard > myQueue > Delayed and delete the job with the icon
image

The job disappears from bullboard and seems to be deleted

But if you query bullmq with

const queue = BullMq.getQueueMq("myQueue");
const repeatableJobs = await queue.getRepeatableJobs()

the deleted job is still existing, but won't be executed in future (to me, it looks like the job lost the repeating property)

I am using @bull-board/fastify: 5.8.1 and bullmq: 4.9.0

@felixmosh
Copy link
Owner

Thank you, I'll check if that is an issue of the lib or the board.
To me it sounds like when ever we call to job.delete, it must handle all of its states...

@Cr0s4k
Copy link

Cr0s4k commented Feb 24, 2024

any update? this behavior is also a bit strange for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants