summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-04-15 10:08:39 +0200
committerantirez <antirez@gmail.com>2017-04-15 10:12:08 +0200
commit271733f4f83552acc52a8baba4ae3fa7bd6b4ba0 (patch)
tree3d9505d645e04a2b7b3384850d7c17d831a8346d
parent3f068b92b98c664ccefb457103068583879609e3 (diff)
downloadredis-271733f4f83552acc52a8baba4ae3fa7bd6b4ba0.tar.gz
Cluster: discard pong times in the future.
However we allow for 500 milliseconds of tolerance, in order to avoid often discarding semantically valid info (the node is up) because of natural few milliseconds desync among servers even when NTP is used. Note that anyway we should ping the node from time to time regardless and discover if it's actually down from our point of view, since no update is accepted while we have an active ping on the node. Related to #3929.
-rw-r--r--src/cluster.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cluster.c b/src/cluster.c
index b23160b90..d5ad85fe7 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -1365,7 +1365,14 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
{
mstime_t pongtime = ntohl(g->pong_received);
pongtime *= 1000; /* Convert back to milliseconds. */
- if (pongtime > node->pong_received) {
+
+ /* Replace the pong time with the received one only if
+ * it's greater than our view but is not in the future
+ * (with 500 milliseconds tolerance) from the POV of our
+ * clock. */
+ if (pongtime <= (server.mstime+500) &&
+ pongtime > node->pong_received)
+ {
node->pong_received = pongtime;
}
}