Skip to content

Commit e582e3c

Browse files
craig[bot]wenyihu6
andcommitted
Merge #153353
153353: mmaprototype: allow rebalancing between stores on the same node r=sumeerbhola a=wenyihu6 Resolves: #153165 Release note: none --- **asim: typo fix** This commit fixes typo in comment and a clusterInfo region setup. --- **mmaprototype: populate conf.NumVoters to conf.NumReplicas if 0** Previously, MMA used the given span config directly. However, the comment on config.NumVoters specifies that if it is set to zero, the voter replica count should default to NumReplicas, which is usually handled by SpanConfig.GetNumVoters(). --- **mmaprototype: allow rebalancing between stores on the same node** Previously, when MMA constructed the candidate set, it excluded stores on nodes that already had replicas, including the current node itself. However, rebalancing replicas across different stores on the same node should be allowed. This commit corrects that logic. Note that the store itself has already been excluded earlier (see https://github.com/cockroachdb/cockroach/blob/da4a31068dc9f268d423aa4d5fd72b29c61942bc/pkg/kv/kvserver/allocator/mmaprototype/allocator_state.go#L614-L623). Co-authored-by: wenyihu6 <[email protected]>
2 parents 729bfdc + ab5a43f commit e582e3c

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,12 @@ func (a *allocatorState) rebalanceStores(
673673
// Also exclude all stores on nodes that have existing replicas.
674674
for _, replica := range rstate.replicas {
675675
storeID := replica.StoreID
676+
if storeID == store.StoreID {
677+
// We don't exclude other stores on this node, since we are allowed to
678+
// transfer the range to them. If the node is overloaded or not fdOK,
679+
// we have already excluded those stores above.
680+
continue
681+
}
676682
nodeID := a.cs.stores[storeID].NodeID
677683
for _, storeID := range a.cs.nodes[nodeID].stores {
678684
storesToExcludeForRange.insert(storeID)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ type internedLeasePreference struct {
252252
func makeNormalizedSpanConfig(
253253
conf *roachpb.SpanConfig, interner *stringInterner,
254254
) (*normalizedSpanConfig, error) {
255+
if conf.NumVoters == 0 {
256+
conf.NumVoters = conf.NumReplicas
257+
}
255258
var normalizedConstraints, normalizedVoterConstraints []internedConstraintsConjunction
256259
var err error
257260
if conf.VoterConstraints != nil {

pkg/kv/kvserver/asim/state/config_loader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var SingleRegionConfig = ClusterInfo{
4040
}
4141

4242
// SingleRegionMultiStoreConfig is a simple cluster config with a single region
43-
// and 3 zones, all zones have 1 node and 6 stores per node.
43+
// and 3 zones, all zones have 1 node and 5 stores per node.
4444
var SingleRegionMultiStoreConfig = ClusterInfo{
4545
StoreDiskCapacityBytes: 1024 << 30, // 1024 GiB
4646
Regions: []Region{
@@ -96,7 +96,7 @@ var ComplexConfig = ClusterInfo{
9696
NewZoneWithSingleStore("US_East_1", 1),
9797
NewZoneWithSingleStore("US_East_2", 2),
9898
NewZoneWithSingleStore("US_East_3", 3),
99-
NewZoneWithSingleStore("US_East_3", 10),
99+
NewZoneWithSingleStore("US_East_4", 10),
100100
},
101101
},
102102
{

pkg/kv/kvserver/asim/state/state_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,9 @@ US_East
755755
US_East_2
756756
│ └── [2 3]
757757
US_East_3
758-
│ └── [4 5 6 7 8 9 10 11 12 13 14 15 16]
758+
│ └── [4 5 6]
759+
US_East_4
760+
│ └── [7 8 9 10 11 12 13 14 15 16]
759761
US_West
760762
US_West_1
761763
└── [17 18]

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_load_cluster.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ assertion type=conformance unavailable=0 under=0 over=0 violating=0
2222

2323
eval duration=2m samples=1 seed=42
2424
----
25-
artifacts[default]: 69397d630700df25
25+
artifacts[default]: 33ad9dff027a296a

pkg/kv/kvserver/asim/tests/testdata/rand/rand_cluster.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ generating settings configurations using static option
6060
sample1: start running
6161
configurations generated using seed 608747136543856411
6262
loaded cluster with
63-
region:US_East [zone=US_East_1(nodes=1,stores=1), zone=US_East_2(nodes=2,stores=1), zone=US_East_3(nodes=3,stores=1), zone=US_East_3(nodes=10,stores=1)]
63+
region:US_East [zone=US_East_1(nodes=1,stores=1), zone=US_East_2(nodes=2,stores=1), zone=US_East_3(nodes=3,stores=1), zone=US_East_4(nodes=10,stores=1)]
6464
region:US_West [zone=US_West_1(nodes=2,stores=1)]
6565
region:EU [zone=EU_1(nodes=3,stores=1), zone=EU_2(nodes=3,stores=1), zone=EU_3(nodes=4,stores=1)]
6666
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
@@ -82,7 +82,9 @@ US_East
8282
US_East_2
8383
│ └── [2 3]
8484
US_East_3
85-
│ └── [4 5 6 7 8 9 10 11 12 13 14 15 16]
85+
│ └── [4 5 6]
86+
US_East_4
87+
│ └── [7 8 9 10 11 12 13 14 15 16]
8688
US_West
8789
US_West_1
8890
└── [17 18]
@@ -128,7 +130,7 @@ sample2: pass
128130
sample3: start running
129131
configurations generated using seed 3534334367214237261
130132
loaded cluster with
131-
region:US_East [zone=US_East_1(nodes=1,stores=1), zone=US_East_2(nodes=2,stores=1), zone=US_East_3(nodes=3,stores=1), zone=US_East_3(nodes=10,stores=1)]
133+
region:US_East [zone=US_East_1(nodes=1,stores=1), zone=US_East_2(nodes=2,stores=1), zone=US_East_3(nodes=3,stores=1), zone=US_East_4(nodes=10,stores=1)]
132134
region:US_West [zone=US_West_1(nodes=2,stores=1)]
133135
region:EU [zone=EU_1(nodes=3,stores=1), zone=EU_2(nodes=3,stores=1), zone=EU_3(nodes=4,stores=1)]
134136
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
@@ -150,7 +152,9 @@ US_East
150152
US_East_2
151153
│ └── [2 3]
152154
US_East_3
153-
│ └── [4 5 6 7 8 9 10 11 12 13 14 15 16]
155+
│ └── [4 5 6]
156+
US_East_4
157+
│ └── [7 8 9 10 11 12 13 14 15 16]
154158
US_West
155159
US_West_1
156160
└── [17 18]
@@ -188,7 +192,7 @@ sample2: pass
188192
sample3: start running
189193
configurations generated using seed 3534334367214237261
190194
loaded cluster with
191-
region:US_East [zone=US_East_1(nodes=1,stores=1), zone=US_East_2(nodes=2,stores=1), zone=US_East_3(nodes=3,stores=1), zone=US_East_3(nodes=10,stores=1)]
195+
region:US_East [zone=US_East_1(nodes=1,stores=1), zone=US_East_2(nodes=2,stores=1), zone=US_East_3(nodes=3,stores=1), zone=US_East_4(nodes=10,stores=1)]
192196
region:US_West [zone=US_West_1(nodes=2,stores=1)]
193197
region:EU [zone=EU_1(nodes=3,stores=1), zone=EU_2(nodes=3,stores=1), zone=EU_3(nodes=4,stores=1)]
194198
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0

pkg/kv/kvserver/asim/tests/testdata/rand/rand_event.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ generating settings configurations using static option
2525
sample1: start running
2626
configurations generated using seed 7894140303635748408
2727
loaded cluster with
28-
region:US_East [zone=US_East_1(nodes=1,stores=1), zone=US_East_2(nodes=2,stores=1), zone=US_East_3(nodes=3,stores=1), zone=US_East_3(nodes=10,stores=1)]
28+
region:US_East [zone=US_East_1(nodes=1,stores=1), zone=US_East_2(nodes=2,stores=1), zone=US_East_3(nodes=3,stores=1), zone=US_East_4(nodes=10,stores=1)]
2929
region:US_West [zone=US_West_1(nodes=2,stores=1)]
3030
region:EU [zone=EU_1(nodes=3,stores=1), zone=EU_2(nodes=3,stores=1), zone=EU_3(nodes=4,stores=1)]
3131
basic ranges with placement_type=even, ranges=1, min_key=0, max_key=200000, replication_factor=3, bytes=0
@@ -47,7 +47,9 @@ US_East
4747
US_East_2
4848
│ └── [2 3]
4949
US_East_3
50-
│ └── [4 5 6 7 8 9 10 11 12 13 14 15 16]
50+
│ └── [4 5 6]
51+
US_East_4
52+
│ └── [7 8 9 10 11 12 13 14 15 16]
5153
US_West
5254
US_West_1
5355
└── [17 18]

0 commit comments

Comments
 (0)