Skip to content

Commit

Permalink
Cluster Manager: fix replica assigment anti-affinity (create)
Browse files Browse the repository at this point in the history
Fix issue redis#5849
  • Loading branch information
artix75 authored and antirez committed Feb 22, 2019
1 parent c0aa669 commit c9c455d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/redis-cli.c
Expand Up @@ -4675,6 +4675,12 @@ static int clusterManagerCommandCreate(int argc, char **argv) {
cursor += slots_per_node;
}

/* Rotating the list sometimes helps to get better initial
* anti-affinity before the optimizer runs. */
clusterManagerNode *first_node = interleaved[0];
for (i = 0; i < (interleaved_len - 1); i++)
interleaved[i] = interleaved[i + 1];
interleaved[interleaved_len - 1] = first_node;
int assign_unused = 0, available_count = interleaved_len;
assign_replicas:
for (i = 0; i < masters_count; i++) {
Expand Down

0 comments on commit c9c455d

Please sign in to comment.