diff options
author | artix <artix2@gmail.com> | 2018-09-17 15:52:47 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2018-09-17 16:26:46 +0200 |
commit | 81c4be42c188d68ed347333addffe062a33d238f (patch) | |
tree | e5197d9dbf12ee864cee2f6342f59db0619c478d /src | |
parent | 12fd92bf67d51dbdd7d993606b8ac5d365a20174 (diff) | |
download | redis-81c4be42c188d68ed347333addffe062a33d238f.tar.gz |
Cluster Manager: clusterManagerFixOpenSlot now counts node's keys in slot
if node is neither migrating nor importing.
Diffstat (limited to 'src')
-rw-r--r-- | src/redis-cli.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c index deac406b0..57f812b90 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -3729,6 +3729,7 @@ static int clusterManagerFixOpenSlot(int slot) { while ((ln = listNext(&li)) != NULL) { clusterManagerNode *n = ln->value; if (n->flags & CLUSTER_MANAGER_FLAG_SLAVE) continue; + int is_migrating = 0, is_importing = 0; if (n->migrating) { for (int i = 0; i < n->migrating_count; i += 2) { sds migrating_slot = n->migrating[i]; @@ -3737,11 +3738,12 @@ static int clusterManagerFixOpenSlot(int slot) { migrating_str = sdscatfmt(migrating_str, "%s%S:%u", sep, n->ip, n->port); listAddNodeTail(migrating, n); + is_migrating = 1; break; } } } - if (n->importing) { + if (!is_migrating && n->importing) { for (int i = 0; i < n->importing_count; i += 2) { sds importing_slot = n->importing[i]; if (atoi(importing_slot) == slot) { @@ -3749,10 +3751,27 @@ static int clusterManagerFixOpenSlot(int slot) { importing_str = sdscatfmt(importing_str, "%s%S:%u", sep, n->ip, n->port); listAddNodeTail(importing, n); + is_importing = 1; break; } } } + /* If the node is neither migrating nor importing and it's not + * the owner, then is added to the importing list in case + * it has keys in the slot. */ + if (!is_migrating && !is_importing && n != owner) { + redisReply *r = CLUSTER_MANAGER_COMMAND(n, + "CLUSTER COUNTKEYSINSLOT %d", slot); + success = clusterManagerCheckRedisReply(n, r, NULL); + if (success && r->integer > 0) { + clusterManagerLogWarn("*** Found keys about slot %d " + "in node %s:%d!\n", slot, n->ip, + n->port); + listAddNodeTail(importing, n); + } + if (r) freeReplyObject(r); + if (!success) goto cleanup; + } } printf("Set as migrating in: %s\n", migrating_str); printf("Set as importing in: %s\n", importing_str); |