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

Flow: order of jobs #673

Closed
milenkovic opened this issue Aug 4, 2021 · 1 comment
Closed

Flow: order of jobs #673

milenkovic opened this issue Aug 4, 2021 · 1 comment

Comments

@milenkovic
Copy link

If I add 2 flows to queue, with concurrency set to 1, I would expect for each flow to complete before next one, however I am getting slightly different behaviour.

await flowProducer.add({
  name: 'renovate-interior1',
  queueName: 'renovate',
  children: [
    { name: 'paint1', data: { place: 'ceiling' }, queueName: 'renovate' },
    { name: 'paint1', data: { place: 'walls' }, queueName: 'renovate' },
    { name: 'fix1', data: { place: 'floor' }, queueName: 'renovate' },
  ],
});
await flowProducer.add({
  name: 'renovate-interior2',
  queueName: 'renovate',
  children: [
    { name: 'paint2', data: { place: 'ceiling' }, queueName: 'renovate' },
    { name: 'paint2', data: { place: 'walls' }, queueName: 'renovate' },
    { name: 'fix2', data: { place: 'floor' }, queueName: 'renovate' },
  ],
});

Order of execution is next:

  • paint1
  • paint1
  • fix1
  • paint2
  • renovate-interior1
  • paint2
  • fix2
  • renovate-interior2

I would expect it to be(after all child jobs are finished, next one is parent job)

  • paint1
  • paint1
  • fix1
  • renovate-interior1
  • paint2
  • paint2
  • fix2
  • renovate-interior2
@manast
Copy link
Contributor

manast commented Aug 6, 2021

First thing to consider with this case is that there are 2 different queues, so they will process jobs independently of each other. But even in the case where you used one single queue for both parent and children, BullMQ can only guarantee that children will be processed before the parent, not that all the children of all parents will be processed before all the parents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants