From 0671d88cabc0fae782a5fe9af0ad388663e6e5c7 Mon Sep 17 00:00:00 2001 From: Saj Goonatilleke Date: Thu, 5 Jul 2012 14:29:27 +1000 Subject: [PATCH] Bug fix: slaves being pinged every second REDIS_REPL_PING_SLAVE_PERIOD controls how often the master should transmit a heartbeat (PING) to its slaves. This period, which defaults to 10, is measured in seconds. Redis 2.4 masters used to ping their slaves every ten seconds, just like it says on the tin. The Redis 2.6 masters I have been experimenting with, on the other hand, ping their slaves *every second*. (master_last_io_seconds_ago never approaches 10.) I think the ping period was inadvertently slashed to one-tenth of its nominal value around the time REDIS_HZ was introduced. This commit reintroduces correct ping schedule behaviour. --- src/redis.h | 2 +- src/replication.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/redis.h b/src/redis.h index 9c9b72f8..1e159083 100644 --- a/src/redis.h +++ b/src/redis.h @@ -544,7 +544,7 @@ struct redisServer { char *masterauth; /* AUTH with this password with master */ char *masterhost; /* Hostname of master */ int masterport; /* Port of master */ - int repl_ping_slave_period; /* Master pings the salve every N seconds */ + int repl_ping_slave_period; /* Master pings the slave every N seconds */ int repl_timeout; /* Timeout after N seconds of master idle */ redisClient *master; /* Client that is master for this slave */ int repl_syncio_timeout; /* Timeout for synchronous I/O calls */ diff --git a/src/replication.c b/src/replication.c index 72b88977..b43e9927 100644 --- a/src/replication.c +++ b/src/replication.c @@ -744,7 +744,7 @@ void replicationCron(void) { * So slaves can implement an explicit timeout to masters, and will * be able to detect a link disconnection even if the TCP connection * will not actually go down. */ - if (!(server.cronloops % (server.repl_ping_slave_period*10))) { + if (!(server.cronloops % (server.repl_ping_slave_period * REDIS_HZ))) { listIter li; listNode *ln; -- 2.47.2