Commit 4f59673d authored by Huang Zhw's avatar Huang Zhw Committed by Oran Agra
Browse files

redis-cli cluster import command may issue wrong MIGRATE command. (#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 a049f629)
(cherry picked from commit d4771a995e99e61e2e8feb92ede06431195b0300)
parent 1655576e
...@@ -6365,9 +6365,9 @@ static int clusterManagerCommandImport(int argc, char **argv) { ...@@ -6365,9 +6365,9 @@ static int clusterManagerCommandImport(int argc, char **argv) {
char cmdfmt[50] = "MIGRATE %s %d %s %d %d"; char cmdfmt[50] = "MIGRATE %s %d %s %d %d";
if (config.cluster_manager_command.flags & CLUSTER_MANAGER_CMD_FLAG_COPY) 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) 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 /* Use SCAN to iterate over the keys, migrating to the
* right node as needed. */ * right node as needed. */
...@@ -6399,8 +6399,7 @@ static int clusterManagerCommandImport(int argc, char **argv) { ...@@ -6399,8 +6399,7 @@ static int clusterManagerCommandImport(int argc, char **argv) {
printf("Migrating %s to %s:%d: ", key, target->ip, target->port); printf("Migrating %s to %s:%d: ", key, target->ip, target->port);
redisReply *r = reconnectingRedisCommand(src_ctx, cmdfmt, redisReply *r = reconnectingRedisCommand(src_ctx, cmdfmt,
target->ip, target->port, target->ip, target->port,
key, 0, timeout, key, 0, timeout);
"COPY", "REPLACE");
if (!r || r->type == REDIS_REPLY_ERROR) { if (!r || r->type == REDIS_REPLY_ERROR) {
if (r && r->str) { if (r && r->str) {
clusterManagerLogErr("Source %s:%d replied with " clusterManagerLogErr("Source %s:%d replied with "
......
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