summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-07-22 17:03:18 +0200
committerantirez <antirez@gmail.com>2016-07-27 12:08:32 +0200
commita1bfe22a80edb208344bfd8be9814249d4aa1448 (patch)
tree0720fc139d22a77dda2e58edba0145fa57d9a99a
parent7ca69aff266691d58d3f01c8670c08e8c5fb7cdd (diff)
downloadredis-a1bfe22a80edb208344bfd8be9814249d4aa1448.tar.gz
Replication: when possible start RDB saving ASAP.
In a previous commit the replication code was changed in order to centralize the BGSAVE for replication trigger in replicationCron(), however after further testings, the 1 second delay imposed by this change is not acceptable. So now the BGSAVE is only delayed if the AOF rewriting process is active. However past comments made sure that replicationCron() is always able to trigger the BGSAVE when needed, making the code generally more robust. The new code is more similar to the initial @oranagra patch where the BGSAVE was delayed only if an AOF rewrite was in progress. Trivia: delaying the BGSAVE uncovered a minor Sentinel issue that is now fixed.
-rw-r--r--src/replication.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/replication.c b/src/replication.c
index c705558a9..b79ec2905 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -666,12 +666,18 @@ void syncCommand(client *c) {
* replicationCron() since we want to delay its start a
* few seconds to wait for more slaves to arrive. */
if (server.repl_diskless_sync_delay)
- serverLog(LL_NOTICE,"Delay next BGSAVE for SYNC");
+ serverLog(LL_NOTICE,"Delay next BGSAVE for diskless SYNC");
} else {
/* Target is disk (or the slave is not capable of supporting
* diskless replication) and we don't have a BGSAVE in progress,
* let's start one. */
- serverLog(LL_NOTICE,"No BGSAVE in progress. Starting one ASAP");
+ if (server.aof_child_pid != -1) {
+ startBgsaveForReplication(c->slave_capa);
+ } else {
+ serverLog(LL_NOTICE,
+ "No BGSAVE in progress, but an AOF rewrite is active. "
+ "BGSAVE for replication delayed");
+ }
}
}