mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
Cluster: don't migrate to a master that never had slaves.
Replica migration algorithm modified so that slaves never try to migrate to masters that were never configured to have slaves in the past. We want the algorithm to take care of masters that remained without *working* slaves, but that used to have slaves according to the cluster configuration.
This commit is contained in:
parent
7eb47ae290
commit
0d9bcb1c12
@ -2674,6 +2674,10 @@ void clusterHandleSlaveMigration(int max_slaves) {
|
||||
|
||||
/* Only iterate over working masters. */
|
||||
if (nodeIsSlave(node) || nodeFailed(node)) continue;
|
||||
/* If this master never had slaves so far, don't migrate. We want
|
||||
* to migrate to a master that remained orphaned, not masters that
|
||||
* were never configured to have slaves. */
|
||||
if (node->numslaves == 0) continue;
|
||||
okslaves = clusterCountNonFailingSlaves(node);
|
||||
|
||||
if (okslaves == 0 && target == NULL && node->numslots > 0)
|
||||
@ -2912,7 +2916,11 @@ void clusterCron(void) {
|
||||
if (nodeIsSlave(myself) && nodeIsMaster(node) && !nodeFailed(node)) {
|
||||
int okslaves = clusterCountNonFailingSlaves(node);
|
||||
|
||||
if (okslaves == 0 && node->numslots > 0) orphaned_masters++;
|
||||
/* A master is orphaned if it is serving a non-zero number of
|
||||
* slots, have no working slaves, but used to have at least one
|
||||
* slave. */
|
||||
if (okslaves == 0 && node->numslots > 0 && node->numslaves)
|
||||
orphaned_masters++;
|
||||
if (okslaves > max_slaves) max_slaves = okslaves;
|
||||
if (nodeIsSlave(myself) && myself->slaveof == node)
|
||||
this_slaves = okslaves;
|
||||
|
Loading…
x
Reference in New Issue
Block a user