Browse Source

fix divide by zero

pull/5637/head
Chris Lu 11 months ago
parent
commit
0d74ac9224
  1. 6
      weed/mq/pub_balancer/allocate.go

6
weed/mq/pub_balancer/allocate.go

@ -69,14 +69,18 @@ func EnsureAssignmentsToActiveBrokers(activeBrokers cmap.ConcurrentMap[string,*B
}
// pick the brokers with the least number of partitions
if len(addedAssignments) > 0 {
pickedBrokers := pickBrokers(activeBrokers, int32(len(addedAssignments)))
for i, assignment := range addedAssignments {
assignment.LeaderBroker = pickedBrokers[i]
}
pickedBrokers = pickBrokers(activeBrokers, int32(len(updatedAssignments)))
}
if len(updatedAssignments) == 0 {
pickedBrokers := pickBrokers(activeBrokers, int32(len(updatedAssignments)))
for i, assignment := range updatedAssignments {
assignment.LeaderBroker = pickedBrokers[i]
}
}
return
}
Loading…
Cancel
Save