Skip to content

Commit 6387cdf

Browse files
committed
fixup! mmaprototype: clean up comments
1 parent 8be1965 commit 6387cdf

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -703,14 +703,12 @@ func sortTargetCandidateSetAndPick(
703703
return cands.candidates[j].StoreID
704704
}
705705

706-
// ensureAnalyzedConstraints populates the constraints for the given range.
707-
// It should be called when computing lease-transfers / rebalancing candidates
708-
// for a range.
706+
// ensureAnalyzedConstraints populates information necessary to handle
707+
// constraint satisfaction for the given range. It uses
708+
// rangeState.{replicas,conf} as inputs to the computation.
709709
//
710-
// NB: given rstate.conf should already be normalized using
711-
// makeNormalizedSpanConfig. The caller is responsible for calling
712-
// clearAnalyzedConstraints when rstate or the rstate.constraints is no longer
713-
// needed.
710+
// NB: Caller is responsible for calling clearAnalyzedConstraints when rstate or
711+
// the rstate.constraints is no longer needed.
714712
func (cs *clusterState) ensureAnalyzedConstraints(rstate *rangeState) {
715713
if rstate.constraints != nil {
716714
return

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -694,24 +694,24 @@ type analyzedConstraints struct {
694694
// satisfiedByReplica[kind][i] contains the set of storeIDs that satisfy
695695
// constraints[i]. These are for stores that satisfy at least one
696696
// constraint. Each store should appear exactly once in the 2D slice
697-
// ac.satisfiedByReplica[kind]. Populated by initialize and used by mmma to
698-
// compute lease-transfer and rebalancing candidates by functions like
699-
// candidatesToReplaceVoterForRebalance. For example,
697+
// ac.satisfiedByReplica[kind]. For example,
700698
// satisfiedByReplica[voterIndex][0] = [1, 2, 3], means that the first
701699
// constraint (constraints[0]) is satisfied by storeIDs 1, 2, and 3.
702700
//
703-
// NB: this does not mean the current replica set satisfies constraints[i]
704-
// since we may populate satisfiedByReplica[nonVoterIndex][i] for voter
705-
// constraints as well. This just means that the store can satisfy
706-
// constraints[i] regardless of the replica type.
701+
// NB: satisfiedByReplica[nonVoterIndex][i] is populated even if this
702+
// analyzedConstraints represents a voter constraint. This is done because
703+
// satisfiedByReplica[voterIndex][i] may not sufficiently satisfy a
704+
// constraint (or even if it does, at a later point one could be
705+
// decommissioning one of the voters), and populating the nonVoterIndex
706+
// allows MMA to decide to promote a non-voter. replica type.
707707
satisfiedByReplica [numReplicaKinds][][]roachpb.StoreID
708708

709709
// ac.satisfiedNoConstraintReplica[kind] contains the set of storeIDs that
710-
// satisfy no constraint. Populated by initialize and used later by mma.
711-
// Even though we are strict about constraint satisfaction, this can happen
712-
// if the SpanConfig changed or the attributes of a store changed. Note that
713-
// if these analyzedConstraints correspond to voterConstraints, there can be
714-
// non-voters here (which is never be used but is harmless).
710+
// satisfy no constraint. Even though we are strict about constraint
711+
// satisfaction, this can happen if the SpanConfig changed or the attributes
712+
// of a store changed. Note that if these analyzedConstraints correspond to
713+
// voterConstraints, there can be non-voters here which is never used but
714+
// harmless.
715715
satisfiedNoConstraintReplica [numReplicaKinds][]roachpb.StoreID
716716
}
717717

@@ -746,10 +746,12 @@ func clear2DSlice[T any](v [][]T) [][]T {
746746
return v
747747
}
748748

749-
// rangeAnalyzedConstraints is a function of the spanConfig and the current
750-
// stores that have replicas for that range (including the ReplicaType). It
751-
// contains information necessary for mma to compute lease-transfer and
752-
// rebalancing candidates.
749+
// rangeAnalyzedConstraints represents the analyzed constraint state for a
750+
// range, derived from the range's span config and current replica placement
751+
// (including ReplicaType). It contains information used to handle constraint
752+
// satisfaction as part of allocation decisions (e.g. helping identify candidate
753+
// stores for range rebalancing, lease transfers, up-replication,
754+
// down-replication, validating whether constraints are satisfied).
753755
//
754756
// LEARNER and VOTER_DEMOTING_LEARNER replicas are ignored.
755757
type rangeAnalyzedConstraints struct {

0 commit comments

Comments
 (0)