From 777cc5b98738df0156b1c822d7fb7851b5ffb4a6 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 19 Sep 2018 11:43:37 +0200 Subject: [PATCH] Module cluster flags: add hooks for NO_FAILOVER flag. --- src/cluster.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 591df418a..381ff827e 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -3216,7 +3216,8 @@ void clusterHandleSlaveMigration(int max_slaves) { * the natural slaves of this instance to advertise their switch from * the old master to the new one. */ if (target && candidate == myself && - (mstime()-target->orphaned_time) > CLUSTER_SLAVE_MIGRATION_DELAY) + (mstime()-target->orphaned_time) > CLUSTER_SLAVE_MIGRATION_DELAY && + !(server.cluster_module_flags & CLUSTER_MODULE_FLAG_NO_FAILOVER)) { serverLog(LL_WARNING,"Migrating to orphaned master %.40s", target->name); @@ -3569,7 +3570,8 @@ void clusterCron(void) { if (nodeIsSlave(myself)) { clusterHandleManualFailover(); - clusterHandleSlaveFailover(); + if (!(server.cluster_module_flags & CLUSTER_MODULE_FLAG_NO_FAILOVER)) + clusterHandleSlaveFailover(); /* If there are orphaned slaves, and we are a slave among the masters * with the max number of non-failing slaves, consider migrating to * the orphaned masters. Note that it does not make sense to try -- GitLab