From 8ca265cdb728799ecec27c2bb5e0d2092a62aa03 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 26 Jun 2013 10:11:20 +0200 Subject: [PATCH] Don't disconnect pre PSYNC replication clients for timeout. Clients using SYNC to replicate are older implementations, such as redis-cli --slave, and are not designed to acknowledge the master with REPLCONF ACK commands, so we don't have any feedback and should not disconnect them on timeout. --- src/redis.h | 1 + src/replication.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/redis.h b/src/redis.h index 5d9dcd349..570a7deff 100644 --- a/src/redis.h +++ b/src/redis.h @@ -219,6 +219,7 @@ #define REDIS_MASTER_FORCE_REPLY (1<<13) /* Queue replies even if is master */ #define REDIS_FORCE_AOF (1<<14) /* Force AOF propagation of current cmd. */ #define REDIS_FORCE_REPL (1<<15) /* Force replication of current cmd. */ +#define REDIS_PRE_PSYNC_SLAVE (1<<16) /* Slave don't understand PSYNC. */ /* Client request types */ #define REDIS_REQ_INLINE 1 diff --git a/src/replication.c b/src/replication.c index 04a74dbdc..196b8d8f3 100644 --- a/src/replication.c +++ b/src/replication.c @@ -505,6 +505,11 @@ void syncCommand(redisClient *c) { * resync. */ if (master_runid[0] != '?') server.stat_sync_partial_err++; } + } else { + /* If a slave uses SYNC, we are dealing with an old implementation + * of the replication protocol (like redis-cli --slave). Flag the client + * so that we don't expect to receive REPLCONF ACK feedbacks. */ + c->flags |= REDIS_PRE_PSYNC_SLAVE; } /* Full resynchronization. */ @@ -1606,6 +1611,7 @@ void replicationCron(void) { redisClient *slave = ln->value; if (slave->replstate != REDIS_REPL_ONLINE) continue; + if (slave->flags & REDIS_PRE_PSYNC_SLAVE) continue; if ((server.unixtime - slave->repl_ack_time) > server.repl_timeout) { char ip[32];