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

Unfulfilled commands sent on wrong database after reconnection #42

Closed
jnackman opened this issue May 21, 2015 · 1 comment
Closed

Unfulfilled commands sent on wrong database after reconnection #42

jnackman opened this issue May 21, 2015 · 1 comment
Labels

Comments

@jnackman
Copy link

Using sentinel, unfulfilled commands are resent before the database has been reselected, causing them to run against the wrong database. This is reproducible with the following code, killing the master before the command has completed:

var Redis = require("ioredis");
var redis = new Redis({
    sentinels: [...],
    name: "mastername",
    db: 1
});

redis.blpop("some-absent-key", 30, function(){});

The output of MONITOR shows the following:

On master:
1432220467.655639 [0 xxx:39015] "info"
1432220467.659202 [0 xxx:39015] "select" "1"
1432220522.605756 [1 xxx:39015] "blpop" "some-absent-key" "30"

... master killed ...

On new master:
1432220532.258167 [0 xxx:60414] "info"
1432220532.258962 [0 xxx:60414] "blpop" "some-absent-key" "30"
1432220563.055939 [0 xxx:60414] "select" "1"

The unfulfilled BLPOP command is executed before the correct database is reselected. Expected behavior is for the correct database to be selected before running the command.

The code responsible for this behavior appears to be in event_handler.js. The correct database is selected for items in offlineQueue (when necessary), but not for items in prevCommandQueue.

@luin luin added the bug label May 21, 2015
@luin luin closed this as completed in dd2ad38 May 21, 2015
@luin
Copy link
Collaborator

luin commented May 21, 2015

Released in 1.3.6

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

2 participants