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
002fcde3
You need to sign in or sign up before continuing.
Commit
002fcde3
authored
May 08, 2020
by
antirez
Browse files
Cluster: refactor ping/data delay handling.
parent
960186a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
002fcde3
...
@@ -3564,15 +3564,17 @@ void clusterCron(void) {
...
@@ -3564,15 +3564,17 @@ void clusterCron(void) {
/* If we are not receiving any data for more than half the cluster
/* If we are not receiving any data for more than half the cluster
* timeout, reconnect the link: maybe there is a connection
* timeout, reconnect the link: maybe there is a connection
* issue even if the node is alive. */
* issue even if the node is alive. */
mstime_t ping_delay = now - node->ping_sent;
mstime_t data_delay = now - node->data_received;
if (node->link && /* is connected */
if (node->link && /* is connected */
now - node->link->ctime >
now - node->link->ctime >
server.cluster_node_timeout && /* was not already reconnected */
server.cluster_node_timeout && /* was not already reconnected */
node->ping_sent && /* we already sent a ping */
node->ping_sent && /* we already sent a ping */
node->pong_received < node->ping_sent && /* still waiting pong */
node->pong_received < node->ping_sent && /* still waiting pong */
/* and we are waiting for the pong more than timeout/2 */
/* and we are waiting for the pong more than timeout/2 */
now - node->ping_sent
> server.cluster_node_timeout/2 &&
ping_delay
> server.cluster_node_timeout/2 &&
/* and in such interval we are not seeing any traffic at all. */
/* and in such interval we are not seeing any traffic at all. */
now - node->data_received
> server.cluster_node_timeout/2)
data_delay
> server.cluster_node_timeout/2)
{
{
/* Disconnect the link, it will be reconnected automatically. */
/* Disconnect the link, it will be reconnected automatically. */
freeClusterLink(node->link);
freeClusterLink(node->link);
...
@@ -3604,18 +3606,18 @@ void clusterCron(void) {
...
@@ -3604,18 +3606,18 @@ void clusterCron(void) {
/* Check only if we have an active ping for this instance. */
/* Check only if we have an active ping for this instance. */
if (node->ping_sent == 0) continue;
if (node->ping_sent == 0) continue;
/* C
ompute the delay of the PONG. Note that if we already received
/* C
heck if this node looks unreachable.
* the PONG, then node->ping_sent
is zero, so can't reach this
*
Note that if we already received
the PONG, then node->ping_sent
*
code at all. */
*
is zero, so can't reach this code at all, so we don't risk of
mstime_t delay = now - node->ping_sent;
* checking for a PONG delay if we didn't sent the PING.
*
/
* We consider every incoming data as proof of liveness, since
* We
also
consider every incoming data as proof of liveness, since
* our cluster bus link is also used for data: under heavy data
* our cluster bus link is also used for data: under heavy data
* load pong delays are possible. */
* load pong delays are possible. */
mstime_t
data
_delay =
now - node->data_received;
mstime_t
node
_delay =
(ping_delay < data_delay) ? ping_delay :
if (data_delay < delay) delay =
data_delay;
data_delay;
if (delay > server.cluster_node_timeout) {
if (
node_
delay > server.cluster_node_timeout) {
/* Timeout reached. Set the node as possibly failing if it is
/* Timeout reached. Set the node as possibly failing if it is
* not already in this state. */
* not already in this state. */
if (!(node->flags & (CLUSTER_NODE_PFAIL|CLUSTER_NODE_FAIL))) {
if (!(node->flags & (CLUSTER_NODE_PFAIL|CLUSTER_NODE_FAIL))) {
...
...
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