Module cluster flags: add hooks for NO_FAILOVER flag.

This commit is contained in:
antirez 2018-09-19 11:43:37 +02:00
parent c202ba2b35
commit 777cc5b987

View File

@ -3216,7 +3216,8 @@ void clusterHandleSlaveMigration(int max_slaves) {
* the natural slaves of this instance to advertise their switch from * the natural slaves of this instance to advertise their switch from
* the old master to the new one. */ * the old master to the new one. */
if (target && candidate == myself && 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", serverLog(LL_WARNING,"Migrating to orphaned master %.40s",
target->name); target->name);
@ -3569,6 +3570,7 @@ void clusterCron(void) {
if (nodeIsSlave(myself)) { if (nodeIsSlave(myself)) {
clusterHandleManualFailover(); clusterHandleManualFailover();
if (!(server.cluster_module_flags & CLUSTER_MODULE_FLAG_NO_FAILOVER))
clusterHandleSlaveFailover(); clusterHandleSlaveFailover();
/* If there are orphaned slaves, and we are a slave among the masters /* If there are orphaned slaves, and we are a slave among the masters
* with the max number of non-failing slaves, consider migrating to * with the max number of non-failing slaves, consider migrating to