Skip to content

Commit 4353441

Browse files
committed
mmaprototype: use >= 0 for emptyVoterConstraintIndex
This commit fixes >= 0 when checking for whether there were valid emptyVoterConstraintIndex and emptyConstraintIndex since 0 is a valid index.
1 parent aab319d commit 4353441

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

pkg/kv/kvserver/allocator/mmaprototype/constraint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ func doStructuralNormalization(conf *normalizedSpanConfig) error {
605605
// has some remainingReplicas, we take them here to satisfy the empty voter
606606
// constraint as much as possible. Only what is remaining in the empty voter
607607
// constraint will then be available for subsequent narrowing.
608-
if emptyVoterConstraintIndex > 0 && emptyConstraintIndex > 0 {
608+
if emptyVoterConstraintIndex >= 0 && emptyConstraintIndex >= 0 {
609609
neededReplicas := conf.voterConstraints[emptyVoterConstraintIndex].numReplicas
610610
if voterConstraints[emptyVoterConstraintIndex].numReplicas != 0 {
611611
panic("programming error")

pkg/kv/kvserver/allocator/mmaprototype/testdata/normalize_config

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,6 @@ output:
609609

610610
# Replicas are not constrained. The voter constraints are promoted to replica
611611
# constraints.
612-
#
613-
# TODO(sumeer): investigate why the normalization also threw an error.
614612
normalize num-replicas=5 num-voters=3
615613
constraint num-replicas=5
616614
voter-constraint num-replicas=1 +region=a +zone=a1
@@ -623,7 +621,6 @@ input:
623621
voter-constraints:
624622
+region=a,+zone=a1:1
625623
+region=a,+zone=a2:1
626-
err=could not satisfy all voter constraints due to non-intersecting conjunctions in voter and all replica constraints
627624
output:
628625
num-replicas=5 num-voters=3
629626
constraints:

0 commit comments

Comments
 (0)