From 319a4c04c7ccfb8add8669726a29ba188fc7e06f Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 6 Jan 2016 12:14:49 +0100 Subject: [PATCH] Cluster: don't send -ASK to MIGRATE. For non existing keys, we don't want to send -ASK redirections to MIGRATE, since when moving slots from the migrating node to the importing node, we want just to ignore keys that are no longer there. They may be expired or deleted between the GETKEYSINSLOT call and the MIGRATE call. Otherwise this causes an error during migrations with redis-trib (or equivalent cluster management tools). --- src/cluster.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 8f07772e..8c2b988b 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -4866,7 +4866,7 @@ void readwriteCommand(redisClient *c) { * REDIS_CLUSTER_REDIR_CROSS_SLOT if the request contains multiple keys that * don't belong to the same hash slot. * - * REDIS_CLUSTER_REDIR_UNSTABLE if the request contains mutliple keys + * REDIS_CLUSTER_REDIR_UNSTABLE if the request contains multiple keys * belonging to the same slot, but the slot is not stable (in migration or * importing state, likely because a resharding is in progress). * @@ -4990,8 +4990,10 @@ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **arg * Then if we have all the keys. */ /* If we don't have all the keys and we are migrating the slot, send - * an ASK redirection. */ - if (migrating_slot && missing_keys) { + * an ASK redirection. With the exception of the MIGRATE command, that + * should just ignore non existing keys when moving keys from a node + * to another. */ + if (migrating_slot && missing_keys && cmd->proc != migrateCommand) { if (error_code) *error_code = REDIS_CLUSTER_REDIR_ASK; return server.cluster->migrating_slots_to[slot]; }