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

[Bug]: Wrong job is picked after rate limit with priority #1915

Closed
1 task done
luddd3 opened this issue May 24, 2023 · 1 comment · Fixed by #1919
Closed
1 task done

[Bug]: Wrong job is picked after rate limit with priority #1915

luddd3 opened this issue May 24, 2023 · 1 comment · Fixed by #1919
Labels
bug Something isn't working

Comments

@luddd3
Copy link

luddd3 commented May 24, 2023

Version

v3.14.0

Platform

NodeJS

What happened?

Jobs with priority are picked out-of-order after rate limiting with priority.

In my example, I expect job1 to always be processed before job2.

How to reproduce.

import { Queue, Worker } from 'bullmq'
import { setTimeout } from 'node:timers/promises'

const host = 'localhost'
const password = 'password'

// Cleanup
// import IORedis from 'ioredis'
// const client = new IORedis({
//   host,
//   password
// })
// await client.flushdb()

const queue = new Queue('myQueue', {
  connection: {
    host,
    password
  }
})

let i = 0
const worker = new Worker(
  'myQueue',
  async job => {
    i++
    console.log(i, 'rate limit', job.name)
    await setTimeout(20)
    await worker.rateLimit(1000)
    throw Worker.RateLimitError()
  },
  {
    connection: {
      host,
      password
    }
  }
)

console.log('add job1')
await queue.add(
  'job1',
  {},
  {
    jobId: 'job1',
    priority: 10 // works if priority is out-commented
  }
)
await setTimeout(50)

console.log('add job2')
await queue.add(
  'job2',
  {},
  {
    jobId: 'job2',
    priority: 10 // works if priority is out-commented
  }
)
await setTimeout(100)

Relevant log output

add job1
1 rate limit job1
add job2
2 rate limit job2
3 rate limit job2
...

Without priority:

add job1
1 rate limit job1
add job2
2 rate limit job1
3 rate limit job1
4 rate limit job1
...

Code of Conduct

  • I agree to follow this project's Code of Conduct
@luddd3 luddd3 added the bug Something isn't working label May 24, 2023
@roggervalf
Copy link
Collaborator

Hi @luddd3, I think I understand your case, thanks for bringing this up.

github-actions bot pushed a commit that referenced this issue May 30, 2023
## [3.14.2](v3.14.1...v3.14.2) (2023-05-30)

### Bug Fixes

* **python:** fix 'install_requires' to include semver ([#1927](#1927)) ([ce86ece](ce86ece))
* **rate-limit:** take in count priority ([#1919](#1919)) fixes [#1915](#1915) ([b8157a3](b8157a3))
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

Successfully merging a pull request may close this issue.

2 participants