Skip to content

Commit 7123720

Browse files
committed
mmaprototype: make mmaid local to clusterState
It is included in the datadriven outputs, so having it be global isn't ideal since then tests change each other's output depending on the order in which they are run. This wasn't an issue so far - only one trace-producing test ever calls into rebalanceStores in `mmaprototype` - but that's about to change.
1 parent 399a4f6 commit 7123720

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,8 @@ type clusterState struct {
13851385
*constraintMatcher
13861386
*localityTierInterner
13871387
meansMemo *meansMemo
1388+
1389+
mmaid int // a counter for rebalanceStores calls, for logging
13881390
}
13891391

13901392
func newClusterState(ts timeutil.TimeSource, interner *stringInterner) *clusterState {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"math/rand"
1313
"slices"
1414
"strings"
15-
"sync/atomic"
1615
"time"
1716

1817
"github.com/cockroachdb/cockroach/pkg/roachpb"
@@ -21,8 +20,6 @@ import (
2120
"github.com/cockroachdb/logtags"
2221
)
2322

24-
var mmaid = atomic.Int64{}
25-
2623
// rebalanceEnv tracks the state and outcomes of a rebalanceStores invocation.
2724
// Recall that such an invocation is on behalf of a local store, but will
2825
// iterate over a slice of shedding stores - these are not necessarily local
@@ -117,7 +114,9 @@ type sheddingStore struct {
117114
func (re *rebalanceEnv) rebalanceStores(
118115
ctx context.Context, localStoreID roachpb.StoreID,
119116
) []PendingRangeChange {
120-
ctx = logtags.AddTag(ctx, "mmaid", mmaid.Add(1))
117+
re.mmaid++
118+
id := re.mmaid
119+
ctx = logtags.AddTag(ctx, "mmaid", id)
121120

122121
log.KvDistribution.VEventf(ctx, 2, "rebalanceStores begins")
123122
// To select which stores are overloaded, we use a notion of overload that

0 commit comments

Comments
 (0)