Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
range balancer: use correct members for div/rem
Issue redpanda-data#24 showed that the range balancer was broken. On first glance, the issue appears to be because the consumerIdx wraps past the end of potentialConsumers, and the obvious fix is to just inc and mod. This would be an incorrect fix. The real problem lies above in determining div and rem. The whole point is that (div*(potentialConsumers) + rem) == num partitions, thus if we drain div and one from rem every loop, then we will never increment past the end of potential consumers, because partitions will be completely drained on the last consumer. The prior logic accidentally made div smaller and rem larger, thus giving too few partitions to each consumer, and then in some scenarios, would cause us to exhaust consumers while still draining partitions. I will be adding unit tests later.
- Loading branch information