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

ioredis blpop command does not work in clustered redis instance #850

Closed
manasa-ei opened this issue Apr 25, 2019 · 7 comments
Closed

ioredis blpop command does not work in clustered redis instance #850

manasa-ei opened this issue Apr 25, 2019 · 7 comments
Labels

Comments

@manasa-ei
Copy link

manasa-ei commented Apr 25, 2019

I am using redis cluster instance as below:

var client = new Redis.Cluster([{
          port: 6380,
          host: '127.0.0.1'
        }, {
          port: 6381,
          host: '127.0.0.1'
        }, {
          port: 6382,
          host: '127.0.0.1'
        }, {
          port: 6383,
          host: '127.0.0.1'
        }, {
          port: 6384,
          host: '127.0.0.1'
        }, {
          port: 6385,
          host: '127.0.0.1'
        }], {
          maxRedirections: 1 // This one changed intentionally so that issue can reproduced at the earliest
        });


client.blpop('{q}:email:jobs', 0, console.log) // I issued this command

Inside sendCommand method I have issued a console log so as to see which command is being issued as below:

Redis.prototype.sendCommand = function (command, stream) {
    console.log('Inside sendCommand method:', command)

Got the output as below:
Note: I have placed only blpop command which I have issued and ignore all other commands.
Inside sendCommand method:

Command {
  name: 'blpop',
  transformed: true,
  isCustomCommand: false,
  replyEncoding: 'utf8',
  errorStack: undefined,
  args: [ '{q}:email:jobs', '0' ],
  callback: [Function: bound consoleCall],
  resolve: [Function],
  reject: [Function],
  promise: Promise { <pending> },
  keys: [ '{q}:email:jobs' ],
  slot: 11958,
  __is_reject_overwritten: true }

Inside sendCommand method:

Command {
  name: 'blpop',
  transformed: true,
  isCustomCommand: false,
  replyEncoding: 'utf8',
  errorStack: undefined,
  args: [ '{q}:email:jobs', '0' ],
  callback: [Function: bound consoleCall],
  resolve: [Function],
  reject: [Function],
  promise: Promise { <pending> },
  keys: [ '{q}:email:jobs' ],
  slot: 11958,
  __is_reject_overwritten: true }

err is:

{ ReplyError: MOVED 11958 127.0.0.1:6382
    at parseError (/Users/manasamishra/xlabprojects/manas-fork/redis-cluster-ioredis/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (/Users/manasamishra/xlabprojects/manas-fork/redis-cluster-ioredis/node_modules/redis-parser/lib/parser.js:302:14) command: { name: 'blpop', args: [ '{q}:email:jobs', '0' ] } }
Error: Too many Cluster redirections. Last error: ReplyError: MOVED 11958 127.0.0.1:6382
    at Cluster.handleError (/Users/manasamishra/xlabprojects/manas-fork/redis-cluster-ioredis/node_modules/ioredis/built/cluster/index.js:534:38)
    at Command.command.reject (/Users/manasamishra/xlabprojects/manas-fork/redis-cluster-ioredis/node_modules/ioredis/built/cluster/index.js:412:23)
    at Redis.exports.returnError (/Users/manasamishra/xlabprojects/manas-fork/redis-cluster-ioredis/node_modules/ioredis/built/redis/parser.js:61:26)
    at JavascriptRedisParser.returnError (/Users/manasamishra/xlabprojects/manas-fork/redis-cluster-ioredis/node_modules/ioredis/built/redis/parser.js:20:19)
    at JavascriptRedisParser.execute (/Users/manasamishra/xlabprojects/manas-fork/redis-cluster-ioredis/node_modules/redis-parser/lib/parser.js:542:14)
    at Socket.<anonymous> (/Users/manasamishra/xlabprojects/manas-fork/redis-cluster-ioredis/node_modules/ioredis/built/redis/event_handler.js:107:26)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)

I believe this thing is failing in 2nd time as I have passed maxRedirections as 1.

@andrewkuk
Copy link

Hi! I'm had the same issue. Is any updates?

@andrewkuk
Copy link

Also want to add that BLPOP command blocks connection until something new will be added to list.
And it looks like library use same connection to update slots https://github.com/luin/ioredis/blob/master/lib/cluster/index.ts#L611, and as connection is blocked by BLPOP command there will be timeout and library will close this connection after timeout.

@manasa-ei
Copy link
Author

@luin Any update on the above issue?

@RidgeA
Copy link

RidgeA commented May 13, 2019

@luin is it reasonable to use a separate connection to discover cluster and slots ?

@luin
Copy link
Collaborator

luin commented May 13, 2019

Sorry for the late response. MOVED errors are caused by the timeouts when refreshing slots with the connection that in the block mode. @manasa-ei I submitted a pull request for this issue to use a separate connection to refresh slots, as suggested by @RidgeA : #867. Could you test on it to see whether the issue has been solved?

@manasa-ei
Copy link
Author

Sorry for the late response. MOVED errors are caused by the timeouts when refreshing slots with the connection that in the block mode. @manasa-ei I submitted a pull request for this issue to use a separate connection to refresh slots, as suggested by @RidgeA : #867. Could you test on it to see whether the issue has been solved?

@luin It seems it is working good with a little modification such as referring timeout function from utils_1 I think it's only a merging issue. While merging this branch this needs to be taken care as the development is done on a previous version.
Please merge it as soon as possible it will help me and others a lot.

@luin luin closed this as completed in 68db71b May 15, 2019
ioredis-robot pushed a commit that referenced this issue May 15, 2019
## [4.9.5](v4.9.4...v4.9.5) (2019-05-15)

### Bug Fixes

* **cluster:** make blocking commands works with cluster ([#867](#867)) ([68db71b](68db71b)), closes [#850](#850) [#850](#850)
@ioredis-robot
Copy link
Collaborator

🎉 This issue has been resolved in version 4.9.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

janus-dev87 added a commit to janus-dev87/ioredis-work that referenced this issue Mar 1, 2024
## [4.9.5](redis/ioredis@v4.9.4...v4.9.5) (2019-05-15)

### Bug Fixes

* **cluster:** make blocking commands works with cluster ([#867](redis/ioredis#867)) ([68db71b](redis/ioredis@68db71b)), closes [#850](redis/ioredis#850) [#850](redis/ioredis#850)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants