Cluster: clusterCron() freq is now 10h. Still ping 1 node every sec.

After the change in clusterCron() frequency of call, we still want to
ping just one random node every second.
This commit is contained in:
antirez 2013-10-09 16:29:14 +02:00
parent e5864c73b6
commit 573c2fea91

View File

@ -1742,6 +1742,9 @@ void clusterCron(void) {
int j, update_state = 0; int j, update_state = 0;
mstime_t min_pong = 0, now = mstime(); mstime_t min_pong = 0, now = mstime();
clusterNode *min_pong_node = NULL; clusterNode *min_pong_node = NULL;
static unsigned long long iteration = 0;
iteration++; /* Number of times this function was called so far. */
/* Check if we have disconnected nodes and re-establish the connection. */ /* Check if we have disconnected nodes and re-establish the connection. */
di = dictGetSafeIterator(server.cluster->nodes); di = dictGetSafeIterator(server.cluster->nodes);
@ -1798,9 +1801,12 @@ void clusterCron(void) {
} }
dictReleaseIterator(di); dictReleaseIterator(di);
/* Ping some random node. Check a few random nodes and ping the one with /* Ping some random node 1 time every 10 iterations, so that we usually ping
* the oldest pong_received time */ * one random node every second. */
for (j = 0; j < 2; j++) { if (!(iteration % 10)) {
/* Check a few random nodes and ping the one with the oldest
* pong_received time. */
for (j = 0; j < 5; j++) {
de = dictGetRandomKey(server.cluster->nodes); de = dictGetRandomKey(server.cluster->nodes);
clusterNode *this = dictGetVal(de); clusterNode *this = dictGetVal(de);
@ -1816,6 +1822,7 @@ void clusterCron(void) {
redisLog(REDIS_DEBUG,"Pinging node %.40s", min_pong_node->name); redisLog(REDIS_DEBUG,"Pinging node %.40s", min_pong_node->name);
clusterSendPing(min_pong_node->link, CLUSTERMSG_TYPE_PING); clusterSendPing(min_pong_node->link, CLUSTERMSG_TYPE_PING);
} }
}
/* Iterate nodes to check if we need to flag something as failing */ /* Iterate nodes to check if we need to flag something as failing */
di = dictGetSafeIterator(server.cluster->nodes); di = dictGetSafeIterator(server.cluster->nodes);