adonis-bull-queue icon indicating copy to clipboard operation
adonis-bull-queue copied to clipboard

Support for redis-cluster

Open jjoek opened this issue 1 year ago • 3 comments

Hey I am using this with aws memory db and I get the following error

ReplyError: CROSSSLOT Keys in request don't hash to the same slot
    at parseError (/app/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (/app/node_modules/redis-parser/lib/parser.js:302:14) {
  command: {
    name: 'evalsha',
    args: [
      '04bc84f52b5c1a1238af36a0c38c474721088663',
      '9',
      'bull:default:wait',
      'bull:default:active',
      'bull:default:priority',
      'bull:default:events',
      'bull:default:stalled',
      'bull:default:limiter',
      'bull:default:delayed',
      'bull:default:paused',
      'bull:default:meta',
      'bull:default:',
      '1722378879336',
      '',
      <Buffer de 00 03 a5 74 6f 6b 65 6e d9 26 61 34 61 65 39 32 37 61 2d 61 32 62 36 2d 34 34 36 39 2d 62 35 39 30 2d 37 38 65 37 34 37 32 64 65 38 64 33 3a 30 ac ... 24 more bytes>
    ]
  }
}

which after some bit of research I found out that the issue has something to do with redis cluster and from bullmq documentation:

bullmq docs on redis cluster

We are supposed to prefix our queues, I did this by adding the prefix option to the queue in my config to something as below:

const queueConfig: QueueConfig = {
  connection: {
    host: Env.get("QUEUE_REDIS_HOST"),
    port: Env.get("QUEUE_REDIS_PORT"),
    password: Env.get("QUEUE_REDIS_PASSWORD"),
  },

  queue: {
    prefix: "{queue-prefix}",
  },

When I run queue listen that is when I get the above error. Any ideas what could be wrong or what I need to update or change

jjoek avatar Jul 30 '24 22:07 jjoek

any update on this , having same issue

shiv122 avatar Mar 11 '25 11:03 shiv122

if anyone still have this issue , use queue prefix and worker name and prefix

import env from '#start/env'
import { defineConfig } from '@rlanz/bull-queue'

export default defineConfig({
  defaultConnection: {
    host: env.get('QUEUE_REDIS_HOST'),
    port: env.get('QUEUE_REDIS_PORT'),
    password: env.get('QUEUE_REDIS_PASSWORD'),
  },
  queue: {
    prefix: '{bullmq}',
  },

  worker: {
    name: '{bullmq}',
    prefix: '{bullmq}',
  },

  jobs: {
    /*
    |--------------------------------------------------------------------------
    | Default Job Attempts
    |--------------------------------------------------------------------------
    |
    | The default number of attempts after which the job will be marked as
    | failed. You can also set the number of attempts on individual jobs
    | as well.
    |
    | @see https://docs.bullmq.io/guide/retrying-failing-jobs
    |
    */
    attempts: 3,

    /*
    |--------------------------------------------------------------------------
    | Auto-Removal of Jobs
    |--------------------------------------------------------------------------
    |
    | Numbers of jobs to keep in the completed and failed queues before they
    | are removed. This is important to keep the size of these queues in
    | control. Set the value to false to disable auto-removal.
    |
    | @see https://docs.bullmq.io/guide/queues/auto-removal-of-jobs
    |
    */
    removeOnComplete: 100,
    removeOnFail: 100,
  },
})

shiv122 avatar Mar 13 '25 06:03 shiv122