summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-01-30 11:54:18 +0100
committerantirez <antirez@gmail.com>2015-01-30 12:18:42 +0100
commit55f2bc646af24528ea12e36268c978d496056633 (patch)
tree08510ef7a5cd43b1128eb0bb0efbed3aaa1e3ca2
parent0f1b9c3db16ccf7b0a8cdd24f2bf10098fbc44f9 (diff)
downloadredis-55f2bc646af24528ea12e36268c978d496056633.tar.gz
Cluster: some bias towwards FAIL/PFAIL nodes in gossip sections.
This improves PFAIL -> FAIL switch. Too late at this point in the RC releases to add proper PFAIL/FAIL separate dictionary to do this in a less randomized way. Tested in practice with experiments that this helps. PFAIL -> FAIL average with 20 nodes and node-timeout set to 5 seconds takes 2.5 seconds without this commit, 1 second with this commit.
-rw-r--r--src/cluster.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cluster.c b/src/cluster.c
index 3712cc7a5..bbad47bd6 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -2158,7 +2158,7 @@ void clusterSendPing(clusterLink *link, int type) {
clusterBuildMessageHdr(hdr,type);
/* Populate the gossip fields */
- int maxiterations = wanted*2;
+ int maxiterations = wanted*3;
while(freshnodes > 0 && gossipcount < wanted && maxiterations--) {
dictEntry *de = dictGetRandomKey(server.cluster->nodes);
clusterNode *this = dictGetVal(de);
@@ -2169,6 +2169,11 @@ void clusterSendPing(clusterLink *link, int type) {
* already, so we just gossip about other nodes. */
if (this == myself) continue;
+ /* Give a bias to FAIL/PFAIL nodes. */
+ if (maxiterations > wanted*2 &&
+ !(this->flags & (REDIS_NODE_PFAIL|REDIS_NODE_FAIL)))
+ continue;
+
/* In the gossip section don't include:
* 1) Nodes in HANDSHAKE state.
* 3) Nodes with the NOADDR flag set.
@@ -2201,8 +2206,6 @@ void clusterSendPing(clusterLink *link, int type) {
gossip->notused2 = 0;
gossipcount++;
}
- redisLog(REDIS_VERBOSE,"WANTED: %d, USED_ITER: %d, GOSSIPCOUNT: %d",
- wanted, wanted*2-maxiterations, gossipcount);
/* Ready to send... fix the totlen fiend and queue the message in the
* output buffer. */