diff options
author | antirez <antirez@gmail.com> | 2017-12-13 16:56:28 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2017-12-13 16:56:28 +0100 |
commit | 6aefa574273d3bce888dd33f2cc4a19dba742560 (patch) | |
tree | 3151a96a958652cd8b4395ec849bc0d37a82203d | |
parent | bf475ff358a42f06ef0ef91f4a23e3b6addaa09e (diff) | |
download | redis-diskless_slave_refresh2.tar.gz |
Clarify in isUnsyncedSlave() top comment what is an unsynced slave.diskless_slave_refresh2
-rw-r--r-- | src/replication.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/replication.c b/src/replication.c index 001205f6d..7ef701b17 100644 --- a/src/replication.c +++ b/src/replication.c @@ -2606,6 +2606,30 @@ long long replicationGetSlaveOffset(void) { return offset; } +/* An unsynced slave is a slave that has no state in order to continue the + * replication with its master. Technically speaking this happens when + * there is no master representation in server.master or server.cached_master. + * + * For instance a slave immediately after a restart is considered to be + * unsynced (with the exception of slaves loading the replication meta + * data from the RDB file, when this is possible). + * Similarly a slave that was told to replicate from another master (via + * SLAVEOF or other ways) but was yet not able to connect the new master + * to sync, is considered to be in unsynced state. + * Basically when a slave is unsynced, the only possible replication + * continuation is to perform a full sync with its master, throw away + * the current dataset, and load the master one. + * + * This concept is used in order to avoid the slave to persist on disk or + * to append to or rewrite the AOF file when it is not useful or safe. + * + * It's especially useful when slave-diskless is enabled with dangerous + * parameters, so that the DB could be flushed away before loading a new + * one from the network, but then the connection drops and the slave remains + * empty. This could only happen when a slave is in unsynced state, so + * preventing an unsynched slave from persisting to disk, means we could not + * end with an empty DB replacing the on disk RDB file. If a restart happens + * the slave will reload its old DB. */ int isUnsyncedSlave() { return server.masterhost && replicationGetSlaveOffsetRaw() == -1; } |