summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2019-12-18 17:11:03 +0100
committerantirez <antirez@gmail.com>2019-12-18 17:11:03 +0100
commitc5bc1c14c0bfb5213b230a1d0dd96c5f24341885 (patch)
tree66e50ebe39fd1becc97916220acdb4b50c3dc731
parentef0b45ece8ee629dc2234f9061e0b28f9159df55 (diff)
downloadredis-c5bc1c14c0bfb5213b230a1d0dd96c5f24341885.tar.gz
Modules: rewrite top function doc of AvoidReplicaTraffic().
-rw-r--r--src/module.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/module.c b/src/module.c
index f6f4ef2b9..26c095b05 100644
--- a/src/module.c
+++ b/src/module.c
@@ -1900,10 +1900,26 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) {
return flags;
}
-/* Returns true when the module should avoid actions that cause traffic to replicas.
- * This is required during manual failover when waiting for the replica
- * to be in perfect sync with the master. Modules doing background operations
- * which are not a result of user traffic should check this flag periodically. */
+/* Returns true if some client sent the CLIENT PAUSE command to the server or
+ * if Redis Cluster is doing a manual failover, and paused tue clients.
+ * This is needed when we have a master with replicas, and want to write,
+ * without adding further data to the replication channel, that the replicas
+ * replication offset, match the one of the master. When this happens, it is
+ * safe to failover the master without data loss.
+ *
+ * However modules may generate traffic by calling RedisModule_Call() with
+ * the "!" flag, or by calling RedisModule_Replicate(), in a context outside
+ * commands execution, for instance in timeout callbacks, threads safe
+ * contexts, and so forth. When modules will generate too much traffic, it
+ * will be hard for the master and replicas offset to match, because there
+ * is more data to send in the replication channel.
+ *
+ * So modules may want to try to avoid very heavy background work that has
+ * the effect of creating data to the replication channel, when this function
+ * returns true. This is mostly useful for modules that have background
+ * garbage collection tasks, or that do writes and replicate such writes
+ * periodically in timer callbacks or other periodic callbacks.
+ */
int RM_AvoidReplicaTraffic() {
return clientsArePaused();
}