Skip to content

Commit 0e1be53

Browse files
committed
PSYNC: More robust handling of unexpected reply to PSYNC.
1 parent 7404b95 commit 0e1be53

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/replication.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,14 @@ int slaveTryPartialResynchronization(int fd) {
956956
if (!runid || !offset || (offset-runid-1) != REDIS_RUN_ID_SIZE) {
957957
redisLog(REDIS_WARNING,
958958
"Master replied with wrong +FULLRESYNC syntax.");
959+
sdsfree(reply);
960+
/* This is an unexpected condition, actually the +FULLRESYNC
961+
* reply means that the master supports PSYNC, but the reply
962+
* format seems wrong. To stay safe we blank the master
963+
* runid to make sure next PSYNCs will fail, and return
964+
* NOT_SUPPORTED to the caller to use SYNC instead. */
965+
memset(server.repl_master_runid,0,REDIS_RUN_ID_SIZE+1);
966+
return PSYNC_NOT_SUPPORTED;
959967
} else {
960968
memcpy(server.repl_master_runid, runid, offset-runid-1);
961969
server.repl_master_runid[REDIS_RUN_ID_SIZE] = '\0';

0 commit comments

Comments
 (0)