Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
81c4be42
Commit
81c4be42
authored
Sep 17, 2018
by
artix
Committed by
antirez
Sep 17, 2018
Browse files
Cluster Manager: clusterManagerFixOpenSlot now counts node's keys in slot
if node is neither migrating nor importing.
parent
12fd92bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-cli.c
View file @
81c4be42
...
...
@@ -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
);
...
...
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