Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ef3ff402
Commit
ef3ff402
authored
Aug 22, 2018
by
yura
Committed by
antirez
Dec 11, 2018
Browse files
redis-cli reshard/rebalance: ability to force replacement on existing keys
parent
ee223fb8
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis-cli.c
View file @
ef3ff402
...
@@ -2826,8 +2826,8 @@ static int clusterManagerMigrateKeysInSlot(clusterManagerNode *source,
...
@@ -2826,8 +2826,8 @@ static int clusterManagerMigrateKeysInSlot(clusterManagerNode *source,
char **err)
char **err)
{
{
int success = 1;
int success = 1;
int
do_fix
=
(
config
.
cluster_manager_command
.
flags
&
int
replace_existing_keys
= (config.cluster_manager_command.flags &
CLUSTER_MANAGER_CMD_FLAG_FIX
);
(
CLUSTER_MANAGER_CMD_FLAG_FIX
| CLUSTER_MANAGER_CMD_FLAG_REPLACE)
);
while (1) {
while (1) {
char *dots = NULL;
char *dots = NULL;
redisReply *reply = NULL, *migrate_reply = NULL;
redisReply *reply = NULL, *migrate_reply = NULL;
...
@@ -2858,13 +2858,14 @@ static int clusterManagerMigrateKeysInSlot(clusterManagerNode *source,
...
@@ -2858,13 +2858,14 @@ static int clusterManagerMigrateKeysInSlot(clusterManagerNode *source,
dots);
dots);
if (migrate_reply == NULL) goto next;
if (migrate_reply == NULL) goto next;
if (migrate_reply->type == REDIS_REPLY_ERROR) {
if (migrate_reply->type == REDIS_REPLY_ERROR) {
if
(
do_fix
&&
strstr
(
migrate_reply
->
str
,
"BUSYKEY"
))
{
int is_busy = strstr(migrate_reply->str, "BUSYKEY") != NULL;
int not_served = strstr(migrate_reply->str, "slot not served") != NULL;
if (replace_existing_keys && (is_busy || not_served)) {
/* If the key already exists, try to migrate keys
/* If the key already exists, try to migrate keys
* adding REPLACE option.
* adding REPLACE option.
* If the key's slot is not served, try to assign slot
* If the key's slot is not served, try to assign slot
* to the target node. */
* to the target node. */
int
is_busy
=
(
strstr
(
migrate_reply
->
str
,
"BUSYKEY"
)
!=
NULL
);
if (not_served)
if
(
strstr
(
migrate_reply
->
str
,
"slot not served"
)
!=
NULL
)
clusterManagerSetSlot(source, target, slot, "node", NULL);
clusterManagerSetSlot(source, target, slot, "node", NULL);
clusterManagerLogWarn("*** Target key exists. "
clusterManagerLogWarn("*** Target key exists. "
"Replacing it for FIX.\n");
"Replacing it for FIX.\n");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment