Commit 00d637f2 authored by antirez's avatar antirez
Browse files

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).
parent 8b3aa734
...@@ -4869,7 +4869,7 @@ void readwriteCommand(client *c) { ...@@ -4869,7 +4869,7 @@ void readwriteCommand(client *c) {
* CLUSTER_REDIR_CROSS_SLOT if the request contains multiple keys that * CLUSTER_REDIR_CROSS_SLOT if the request contains multiple keys that
* don't belong to the same hash slot. * don't belong to the same hash slot.
* *
* CLUSTER_REDIR_UNSTABLE if the request contains mutliple keys * CLUSTER_REDIR_UNSTABLE if the request contains multiple keys
* belonging to the same slot, but the slot is not stable (in migration or * belonging to the same slot, but the slot is not stable (in migration or
* importing state, likely because a resharding is in progress). * importing state, likely because a resharding is in progress).
* *
...@@ -4993,8 +4993,10 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in ...@@ -4993,8 +4993,10 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
* Then if we have all the keys. */ * Then if we have all the keys. */
/* If we don't have all the keys and we are migrating the slot, send /* If we don't have all the keys and we are migrating the slot, send
* an ASK redirection. */ * an ASK redirection. With the exception of the MIGRATE command, that
if (migrating_slot && missing_keys) { * 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 = CLUSTER_REDIR_ASK; if (error_code) *error_code = CLUSTER_REDIR_ASK;
return server.cluster->migrating_slots_to[slot]; return server.cluster->migrating_slots_to[slot];
} }
......
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