summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2018-01-16 10:10:42 +0200
committerantirez <antirez@gmail.com>2018-01-18 12:16:05 +0100
commit8d9dff84ce6e04d34f3042105273df080facf46d (patch)
tree38b1cd4abd8d5bafe35dc294525854f029b25c4f
parentfba2e169f93706e382564d592b6a2eaa1250e8a2 (diff)
downloadredis-8d9dff84ce6e04d34f3042105273df080facf46d.tar.gz
PSYNC2 fix - promoted slave should hold on to it's backlog
after a slave is promoted (assuming it has no slaves and it booted over an hour ago), it will lose it's replication backlog at the next replication cron, rather than waiting for slaves to connect to it. so on a simple master/slave faiover, if the new slave doesn't connect immediately, it may be too later and PSYNC2 will fail.
-rw-r--r--src/replication.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/replication.c b/src/replication.c
index cf4db3e3a..97516300e 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -1970,6 +1970,11 @@ void replicationUnsetMaster(void) {
* with PSYNC version 2, there is no need for full resync after a
* master switch. */
server.slaveseldb = -1;
+
+ /* We need to remember the time when we became a master and lost all
+ * attached slaves (if we had any), as after some time we'll free the
+ * replication backlog. */
+ server.repl_no_slaves_since = server.unixtime;
}
/* This function is called when the slave lose the connection with the