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
0f1b9c3d
Commit
0f1b9c3d
authored
Jan 30, 2015
by
antirez
Browse files
More correct wanted / maxiterations values in clusterSendPing().
parent
96368c2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
0f1b9c3d
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include <sys/socket.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/file.h>
#include <math.h>
/* A global reference to myself is handy to make code more clear.
/* A global reference to myself is handy to make code more clear.
* Myself always points to server.cluster->myself, that is, the clusterNode
* Myself always points to server.cluster->myself, that is, the clusterNode
...
@@ -2136,8 +2137,9 @@ void clusterSendPing(clusterLink *link, int type) {
...
@@ -2136,8 +2137,9 @@ void clusterSendPing(clusterLink *link, int type) {
* Since we have non-voting slaves that lower the probability of an entry
* Since we have non-voting slaves that lower the probability of an entry
* to feature our node, we set the number of entires per packet as
* to feature our node, we set the number of entires per packet as
* 10% of the total nodes we have. */
* 10% of the total nodes we have. */
wanted
=
f
resh
nodes
/
10
;
wanted = f
loor(dictSize(server.cluster->
nodes
)
/10
)
;
if (wanted < 3) wanted = 3;
if (wanted < 3) wanted = 3;
if (wanted > freshnodes) wanted = freshnodes;
/* Compute the maxium totlen to allocate our buffer. We'll fix the totlen
/* Compute the maxium totlen to allocate our buffer. We'll fix the totlen
* later according to the number of gossip sections we really were able
* later according to the number of gossip sections we really were able
...
@@ -2156,7 +2158,7 @@ void clusterSendPing(clusterLink *link, int type) {
...
@@ -2156,7 +2158,7 @@ void clusterSendPing(clusterLink *link, int type) {
clusterBuildMessageHdr(hdr,type);
clusterBuildMessageHdr(hdr,type);
/* Populate the gossip fields */
/* Populate the gossip fields */
int
maxiterations
=
wanted
+
10
;
int maxiterations = wanted
*2
;
while(freshnodes > 0 && gossipcount < wanted && maxiterations--) {
while(freshnodes > 0 && gossipcount < wanted && maxiterations--) {
dictEntry *de = dictGetRandomKey(server.cluster->nodes);
dictEntry *de = dictGetRandomKey(server.cluster->nodes);
clusterNode *this = dictGetVal(de);
clusterNode *this = dictGetVal(de);
...
@@ -2199,6 +2201,8 @@ void clusterSendPing(clusterLink *link, int type) {
...
@@ -2199,6 +2201,8 @@ void clusterSendPing(clusterLink *link, int type) {
gossip->notused2 = 0;
gossip->notused2 = 0;
gossipcount++;
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
/* Ready to send... fix the totlen fiend and queue the message in the
* output buffer. */
* output buffer. */
...
...
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