Fix div by 0 in redis-cli cluster creation (#8553)

This could happen on an invalid use, when trying to create a cluster with
a single node and provide it's address 3 time to satisfy redis-cli requirements.
This commit is contained in:
Pavlo Yatsukhnenko 2021-02-28 15:28:09 +02:00 committed by GitHub
parent 17c226b070
commit 18ff8cd1fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2972,7 +2972,7 @@ static void clusterManagerOptimizeAntiAffinity(clusterManagerNodeArray *ipnodes,
ip_count, ip_count,
&offenders, &offenders,
&offending_len); &offending_len);
if (score == 0) break; // Optimal anti affinity reached if (score == 0 || offending_len == 0) break; // Optimal anti affinity reached
/* We'll try to randomly swap a slave's assigned master causing /* We'll try to randomly swap a slave's assigned master causing
* an affinity problem with another random slave, to see if we * an affinity problem with another random slave, to see if we
* can improve the affinity. */ * can improve the affinity. */