diff --git a/src/cluster.c b/src/cluster.c index 5c25d8d3f2af70b7bbbd3a2686e9809d528f084c..b17a8489ff56f4c1c77d94e962e5177ddfe099e9 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -2007,7 +2007,7 @@ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **arg * it is assigned to a different node, but only if the client * issued an ASKING command before. */ if (server.cluster->importing_slots_from[slot] != NULL && - c->flags & REDIS_ASKING) { + (c->flags & REDIS_ASKING || cmd->flags & REDIS_CMD_ASKING)) { return server.cluster->myself; } /* It's not a -ASK case. Base case: just return the right node. */ diff --git a/src/redis.c b/src/redis.c index 9bc797d1690c30c980d6210b8fb2d4426b83de80..e398fa5da188b2123c42965518e4e37a41a67ad9 100644 --- a/src/redis.c +++ b/src/redis.c @@ -111,6 +111,8 @@ struct redisCommand *commandTable; * server this data. Normally no command is accepted in this condition * but just a few. * M: Do not automatically propagate the command on MONITOR. + * k: Perform an implicit ASKING for this command, so the command will be + * accepted in cluster mode if the slot is marked as 'importing'. */ struct redisCommand redisCommandTable[] = { {"get",getCommand,2,"r",0,NULL,1,1,1,0,0}, @@ -242,6 +244,7 @@ struct redisCommand redisCommandTable[] = { {"unwatch",unwatchCommand,1,"rs",0,NULL,0,0,0,0,0}, {"cluster",clusterCommand,-2,"ar",0,NULL,0,0,0,0,0}, {"restore",restoreCommand,-4,"awm",0,NULL,1,1,1,0,0}, + {"restore-asking",restoreCommand,-4,"awmk",0,NULL,1,1,1,0,0}, {"migrate",migrateCommand,-6,"aw",0,NULL,0,0,0,0,0}, {"asking",askingCommand,1,"r",0,NULL,0,0,0,0,0}, {"dump",dumpCommand,2,"ar",0,NULL,1,1,1,0,0}, @@ -1453,6 +1456,7 @@ void populateCommandTable(void) { case 'l': c->flags |= REDIS_CMD_LOADING; break; case 't': c->flags |= REDIS_CMD_STALE; break; case 'M': c->flags |= REDIS_CMD_SKIP_MONITOR; break; + case 'k': c->flags |= REDIS_CMD_ASKING; break; default: redisPanic("Unsupported command flag"); break; } f++; diff --git a/src/redis.h b/src/redis.h index be523e0d8d801af00017a81a5efc0e3dcd0c6d3b..3f25e32a315d89fa0ff4b1bee62001bfec8a0701 100644 --- a/src/redis.h +++ b/src/redis.h @@ -122,6 +122,7 @@ #define REDIS_CMD_LOADING 512 /* "l" flag */ #define REDIS_CMD_STALE 1024 /* "t" flag */ #define REDIS_CMD_SKIP_MONITOR 2048 /* "M" flag */ +#define REDIS_CMD_ASKING 4096 /* "k" flag */ /* Object types */ #define REDIS_STRING 0