Skip to content

Commit

Permalink
redis-cli cluster import command may issue wrong MIGRATE command. (re…
Browse files Browse the repository at this point in the history
…dis#8945)

In clusterManagerCommandImport strcat was used to concat COPY and
REPLACE, the space maybe not enough.
If we use --cluster-replace but not --cluster-copy, the MIGRATE
command contained COPY instead of REPLACE.

(cherry picked from commit a049f62)
  • Loading branch information
huangzhw authored and oranagra committed Jul 18, 2021
1 parent f4702b8 commit d4771a9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/redis-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -6540,9 +6540,9 @@ static int clusterManagerCommandImport(int argc, char **argv) {
}

if (config.cluster_manager_command.flags & CLUSTER_MANAGER_CMD_FLAG_COPY)
strcat(cmdfmt, " %s");
cmdfmt = sdscat(cmdfmt," COPY");
if (config.cluster_manager_command.flags & CLUSTER_MANAGER_CMD_FLAG_REPLACE)
strcat(cmdfmt, " %s");
cmdfmt = sdscat(cmdfmt," REPLACE");

/* Use SCAN to iterate over the keys, migrating to the
* right node as needed. */
Expand Down Expand Up @@ -6574,8 +6574,7 @@ static int clusterManagerCommandImport(int argc, char **argv) {
printf("Migrating %s to %s:%d: ", key, target->ip, target->port);
redisReply *r = reconnectingRedisCommand(src_ctx, cmdfmt,
target->ip, target->port,
key, 0, timeout,
"COPY", "REPLACE");
key, 0, timeout);
if (!r || r->type == REDIS_REPLY_ERROR) {
if (r && r->str) {
clusterManagerLogErr("Source %s:%d replied with "
Expand Down

0 comments on commit d4771a9

Please sign in to comment.