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

problem with redis cluster #906

Closed
amirAlamian opened this issue Dec 1, 2021 · 3 comments
Closed

problem with redis cluster #906

amirAlamian opened this issue Dec 1, 2021 · 3 comments

Comments

@amirAlamian
Copy link

amirAlamian commented Dec 1, 2021

Hi I have a Redis cluster with 6 nodes. 3 masters and others are slaves. when I start my application I see this error throws from ioredis

2021-12-01T12:03:24.226187083Z ReplyError: CROSSSLOT Keys in request don't hash to the same slot
2021-12-01T12:03:24.226224973Z     at parseError (/app/node_modules/redis-parser/lib/parser.js:179:12)
2021-12-01T12:03:24.226230093Z     at parseType (/app/node_modules/redis-parser/lib/parser.js:302:14) {
2021-12-01T12:03:24.226233840Z   command: {
2021-12-01T12:03:24.226237206Z     name: 'evalsha',
2021-12-01T12:03:24.226240963Z     args: [
2021-12-01T12:03:24.226244369Z       '81beff9dde03a16bbfc8557eaca2b17a86216314',
2021-12-01T12:03:24.226247776Z       '7',
2021-12-01T12:03:24.226250942Z       'bull:outlookNotificationQueue:delayed',
2021-12-01T12:03:24.226254298Z       'bull:outlookNotificationQueue:wait',
2021-12-01T12:03:24.226268264Z       'bull:outlookNotificationQueue:priority',
2021-12-01T12:03:24.226272292Z       'bull:outlookNotificationQueue:paused',
2021-12-01T12:03:24.226275848Z       'bull:outlookNotificationQueue:meta',
2021-12-01T12:03:24.226279435Z       'bull:outlookNotificationQueue:events',
2021-12-01T12:03:24.226283162Z       'bull:outlookNotificationQueue:delay',
2021-12-01T12:03:24.226287089Z       'bull:outlookNotificationQueue:',
2021-12-01T12:03:24.226290636Z       '1638360204223'
2021-12-01T12:03:24.226293872Z     ]
2021-12-01T12:03:24.226296867Z   }
2021-12-01T12:03:24.226300554Z }

I did some research about this CROSSSLOT error and I found that to avoid getting this error I must use HASH TAG. Bullmq use this Hash Tag feature when you Set prefix key in connection object when you are creating queues or workers. so I did this and again I get this error.
my redis cluster connection is like this

    const redisNodes: Redis.ClusterNode[] = [
      {
        port: parseInt(REDIS_PORT),
        host: REDIS_HOST,
      },
    ];
new Redis.Cluster(redisNodes)

and I use the queue or worker name as prefix. I create queues using this function

  createNewQueue = (name: string defaultJobOptions?: JobsOptions) => {
    const queue = new BullQueue(name, { prefix: name, connection: this.connectionToRedis, defaultJobOptions });
    return queue;
  };

Any help?

@DanielNetzer
Copy link

DanielNetzer commented Jan 1, 2022

Hi @amirAlamian we encountered the same issue, it seems that encapsulating prefix names with curly brackets solves it.
e.g. {somePrefix}

@manast
Copy link
Contributor

manast commented Jan 10, 2022

This is documented here: https://docs.bullmq.io/bull/patterns/redis-cluster

@manast manast closed this as completed Jan 10, 2022
@ammirator-administrator
Copy link

@manast
Documentation is a bit incomplete just by adding prefix to Queue instance is not enough, for workers we have to do the same and it gets resolved

Leaving this here in case someone have the same problem

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

No branches or pull requests

4 participants