summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-09-19 10:33:14 +0200
committerantirez <antirez@gmail.com>2017-09-19 10:33:14 +0200
commitb75ae0bbea794dbfd6549d308ab29f9b963e0722 (patch)
tree04c141a30127d293e8cb5f22b709666aea041f4a
parent8885921dfbdd5fee2d5904f6f296435f038f45e1 (diff)
downloadredis-b75ae0bbea794dbfd6549d308ab29f9b963e0722.tar.gz
PSYNC2: Create backlog on slave partial sync as well.
A slave may be started with an RDB file able to provide enough slave to perform a successful partial SYNC with its master. However in such a case, how outlined in issue #4268, the slave backlog will not be started, since it was only initialized on full syncs attempts. This creates different problems with successive PSYNC attempts that will always result in full synchronizations. Thanks to @fdingiit for discovering the issue.
-rw-r--r--src/replication.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/replication.c b/src/replication.c
index 6be5d2631..97ce9608d 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -1531,6 +1531,11 @@ int slaveTryPartialResynchronization(int fd, int read_reply) {
/* Setup the replication to continue. */
sdsfree(reply);
replicationResurrectCachedMaster(fd);
+
+ /* If this instance was restarted and we read the metadata to
+ * PSYNC from the persistence file, our replication backlog could
+ * be still not initialized. Create it. */
+ if (server.repl_backlog == NULL) createReplicationBacklog();
return PSYNC_CONTINUE;
}