File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
pkg/kv/kvserver/allocator/mmaprototype Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -467,7 +467,7 @@ func doStructuralNormalization(conf *normalizedSpanConfig) error {
467467 // don't know the semantics of regions, zones or the universe of possible
468468 // values of the zone.
469469 index := 0
470- for rels [index ].voterAndAllRel == conjPossiblyIntersecting {
470+ for index < len ( rels ) && rels [index ].voterAndAllRel == conjPossiblyIntersecting {
471471 index ++
472472 }
473473 var err error
@@ -691,7 +691,7 @@ func doStructuralNormalization(conf *normalizedSpanConfig) error {
691691 })
692692 // Ignore conjPossiblyIntersecting.
693693 index = 0
694- for rels [index ].voterAndAllRel == conjPossiblyIntersecting {
694+ for index < len ( rels ) && rels [index ].voterAndAllRel == conjPossiblyIntersecting {
695695 index ++
696696 }
697697 voterConstraintHasEqualityWithConstraint := make ([]bool , len (conf .voterConstraints ))
Original file line number Diff line number Diff line change @@ -634,3 +634,26 @@ output:
634634 +region=a,+zone=a1:1
635635 +region=a,+zone=a2:1
636636 :1
637+
638+ # Regression test for out-of-bounds access bug when all relationships are
639+ # conjPossiblyIntersecting. The voter constraint (+region=a,+zone=a1) and the
640+ # all-replica constraint (+region=a,+zone=a2) share +region=a but differ in
641+ # zone constraints, creating a possibly intersecting relationship. By not
642+ # constraining all replicas to a2, voters can be in a1 while others are in a2.
643+ normalize num-replicas=3 num-voters=3
644+ constraint num-replicas=3 +region=a +zone=a2
645+ voter-constraint num-replicas=3 +region=a +zone=a1
646+ ----
647+ input:
648+ num-replicas=3 num-voters=3
649+ constraints:
650+ +region=a,+zone=a2:3
651+ voter-constraints:
652+ +region=a,+zone=a1:3
653+ err=could not satisfy all voter constraints due to non-intersecting conjunctions in voter and all replica constraints
654+ output:
655+ num-replicas=3 num-voters=3
656+ constraints:
657+ +region=a,+zone=a2:3
658+ voter-constraints:
659+ +region=a,+zone=a1:3
You can’t perform that action at this time.
0 commit comments