]> git.saurik.com Git - redis.git/commitdiff
Bug fix: slaves being pinged every second
authorSaj Goonatilleke <sg@redu.cx>
Thu, 5 Jul 2012 04:29:27 +0000 (14:29 +1000)
committerSaj Goonatilleke <sg@redu.cx>
Thu, 5 Jul 2012 04:29:27 +0000 (14:29 +1000)
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
src/replication.c

index 9a9b511c0f25bddd71845934da43c31ded09a4d3..e79855d8699165b37a9b8266b382b7523e176a92 100644 (file)
@@ -670,7 +670,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 */
index 45a223b8e36d4dbc333d83122052442ce22c747d..3f7c2914dcecaeb2b52be4659a8fd6655eec0821 100644 (file)
@@ -668,7 +668,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;