Fix rebalancer adding extra replicas
Fix the rebalancer adding extra replicas when downsizing clusters due to
not clearing the instance state map before writing in the new segment
assignment.
@@ -186,6 +186,8 @@ public class PinotSegmentRebalancer extends PinotZKChanger {
public IdealState apply(@Nullable IdealState idealState) {
for (String segmentId : newMapping.keySet()) {
Map<String, String> instanceStateMap = newMapping.get(segmentId);
+
+ idealState.getInstanceStateMap(segmentId).clear();
for (String instanceId : instanceStateMap.keySet()) {
idealState.setPartitionState(segmentId, instanceId, instanceStateMap.get(instanceId));
}
