summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-10-04 12:25:09 +0200
committerantirez <antirez@gmail.com>2013-10-04 12:27:40 +0200
commitc8c1006cf4dd01ae8df844ae2c8fe36ca1bff5bc (patch)
tree1d9689ccf8f5f52560b052cbfdb591b2773ecbbc
parent81f614ef6f1eaf5c1c5699cf00b87c1c02da216e (diff)
downloadredis-c8c1006cf4dd01ae8df844ae2c8fe36ca1bff5bc.tar.gz
PSYNC: safer handling of PSYNC requests.
There was a bug that over-esteemed the amount of backlog available, however this could only happen when a slave was asking for an offset that was in the "future" compared to the master replication backlog. Now this case is handled well and logged as an incident in the master log file.
-rw-r--r--src/replication.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/replication.c b/src/replication.c
index 3abfdf160..2652b2933 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -356,10 +356,14 @@ int masterTryPartialResynchronization(redisClient *c) {
REDIS_OK) goto need_full_resync;
if (!server.repl_backlog ||
psync_offset < server.repl_backlog_off ||
- psync_offset >= (server.repl_backlog_off + server.repl_backlog_size))
+ psync_offset > (server.repl_backlog_off + server.repl_backlog_histlen))
{
redisLog(REDIS_NOTICE,
"Unable to partial resync with the slave for lack of backlog (Slave request was: %lld).", psync_offset);
+ if (psync_offset > server.master_repl_offset) {
+ redisLog(REDIS_WARNING,
+ "Warning: slave tried to PSYNC with an offset that is greater than the master replication offset.");
+ }
goto need_full_resync;
}