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
d0992d6e
Commit
d0992d6e
authored
Feb 26, 2013
by
antirez
Browse files
Cluster: a few random fixes to the new failure detection.
parent
f288b075
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
d0992d6e
...
@@ -567,11 +567,12 @@ void markNodeAsFailingIfNeeded(clusterNode *node) {
...
@@ -567,11 +567,12 @@ void markNodeAsFailingIfNeeded(clusterNode *node) {
* node, so that no election was possible. */
* node, so that no election was possible. */
void
clearNodeFailureIfNeeded
(
clusterNode
*
node
)
{
void
clearNodeFailureIfNeeded
(
clusterNode
*
node
)
{
if
(
node
->
flags
&
REDIS_NODE_FAIL
&&
!
node
->
numslaves
)
{
if
(
node
->
flags
&
REDIS_NODE_FAIL
&&
!
node
->
numslaves
)
{
node
->
flags
&=
~
REDIS_NODE_FAIL
;
clusterUpdateState
();
redisLog
(
REDIS_NOTICE
,
redisLog
(
REDIS_NOTICE
,
"Clear FAIL state for node %.40s: is reachable and has no slaves."
,
"Clear FAIL state for node %.40s: is reachable and has no slaves."
,
node
->
name
);
node
->
name
);
node
->
flags
&=
~
REDIS_NODE_FAIL
;
clusterUpdateState
();
clusterSaveConfigOrDie
();
}
}
}
}
...
@@ -618,7 +619,9 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
...
@@ -618,7 +619,9 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
node
->
pong_received
=
ntohl
(
g
->
pong_received
);
node
->
pong_received
=
ntohl
(
g
->
pong_received
);
}
}
/* Handle failure reports, only when the sender is a master. */
/* Handle failure reports, only when the sender is a master. */
if
(
sender
&&
sender
->
flags
&
REDIS_NODE_MASTER
)
{
if
(
sender
&&
sender
->
flags
&
REDIS_NODE_MASTER
&&
node
!=
server
.
cluster
->
myself
)
{
if
(
flags
&
(
REDIS_NODE_FAIL
|
REDIS_NODE_PFAIL
))
{
if
(
flags
&
(
REDIS_NODE_FAIL
|
REDIS_NODE_PFAIL
))
{
if
(
clusterNodeAddFailureReport
(
node
,
sender
))
{
if
(
clusterNodeAddFailureReport
(
node
,
sender
))
{
redisLog
(
REDIS_NOTICE
,
redisLog
(
REDIS_NOTICE
,
...
@@ -1239,7 +1242,14 @@ void clusterCron(void) {
...
@@ -1239,7 +1242,14 @@ void clusterCron(void) {
if
(
node
->
ping_sent
==
0
||
if
(
node
->
ping_sent
==
0
||
node
->
ping_sent
<=
node
->
pong_received
)
continue
;
node
->
ping_sent
<=
node
->
pong_received
)
continue
;
delay
=
time
(
NULL
)
-
node
->
pong_received
;
/* If we never received a pong, use the ping time to compute
* the delay. */
if
(
node
->
pong_received
)
{
delay
=
time
(
NULL
)
-
node
->
pong_received
;
}
else
{
delay
=
time
(
NULL
)
-
node
->
ping_sent
;
}
if
(
delay
<
server
.
cluster
->
node_timeout
)
{
if
(
delay
<
server
.
cluster
->
node_timeout
)
{
/* The PFAIL condition can be reversed without external
/* The PFAIL condition can be reversed without external
* help if it is not transitive (that is, if it does not
* help if it is not transitive (that is, if it does not
...
...
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