Commit 634c64dd authored by Salvatore Sanfilippo's avatar Salvatore Sanfilippo Committed by GitHub
Browse files

Merge pull request #4075 from sgn1/brpop_keys

Fix Issues in blocking commands in cluster mode.
parents 365dd037 f85f36f5
...@@ -5418,8 +5418,9 @@ int clusterRedirectBlockedClientIfNeeded(client *c) { ...@@ -5418,8 +5418,9 @@ int clusterRedirectBlockedClientIfNeeded(client *c) {
return 1; return 1;
} }
/* All keys must belong to the same slot, so check first key only. */
di = dictGetIterator(c->bpop.keys); di = dictGetIterator(c->bpop.keys);
while((de = dictNext(di)) != NULL) { if ((de = dictNext(di)) != NULL) {
robj *key = dictGetKey(de); robj *key = dictGetKey(de);
int slot = keyHashSlot((char*)key->ptr, sdslen(key->ptr)); int slot = keyHashSlot((char*)key->ptr, sdslen(key->ptr));
clusterNode *node = server.cluster->slots[slot]; clusterNode *node = server.cluster->slots[slot];
...@@ -5437,6 +5438,7 @@ int clusterRedirectBlockedClientIfNeeded(client *c) { ...@@ -5437,6 +5438,7 @@ int clusterRedirectBlockedClientIfNeeded(client *c) {
clusterRedirectClient(c,node,slot, clusterRedirectClient(c,node,slot,
CLUSTER_REDIR_MOVED); CLUSTER_REDIR_MOVED);
} }
dictReleaseIterator(di);
return 1; return 1;
} }
} }
......
...@@ -152,7 +152,7 @@ struct redisCommand redisCommandTable[] = { ...@@ -152,7 +152,7 @@ struct redisCommand redisCommandTable[] = {
{"linsert",linsertCommand,5,"wm",0,NULL,1,1,1,0,0}, {"linsert",linsertCommand,5,"wm",0,NULL,1,1,1,0,0},
{"rpop",rpopCommand,2,"wF",0,NULL,1,1,1,0,0}, {"rpop",rpopCommand,2,"wF",0,NULL,1,1,1,0,0},
{"lpop",lpopCommand,2,"wF",0,NULL,1,1,1,0,0}, {"lpop",lpopCommand,2,"wF",0,NULL,1,1,1,0,0},
{"brpop",brpopCommand,-3,"ws",0,NULL,1,1,1,0,0}, {"brpop",brpopCommand,-3,"ws",0,NULL,1,-2,1,0,0},
{"brpoplpush",brpoplpushCommand,4,"wms",0,NULL,1,2,1,0,0}, {"brpoplpush",brpoplpushCommand,4,"wms",0,NULL,1,2,1,0,0},
{"blpop",blpopCommand,-3,"ws",0,NULL,1,-2,1,0,0}, {"blpop",blpopCommand,-3,"ws",0,NULL,1,-2,1,0,0},
{"llen",llenCommand,2,"rF",0,NULL,1,1,1,0,0}, {"llen",llenCommand,2,"rF",0,NULL,1,1,1,0,0},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment