Skip to content

Commit a8fed33

Browse files
committed
fix conflict
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
2 parents a030383 + 0646a37 commit a8fed33

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

server/cluster/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ func (c *RaftCluster) putStoreImpl(store *metapb.Store, force bool) error {
10841084
labels := store.GetLabels()
10851085
if !force {
10861086
// If 'force' isn't set, the given labels will merge into those labels which already existed in the store.
1087-
labels = s.MergeLabels(labels)
1087+
labels = s.Clone().MergeLabels(labels)
10881088
}
10891089
// Update an existed store.
10901090
s = s.Clone(

server/schedule/region_scatterer_test.go

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ func TestRegionHasLearner(t *testing.T) {
608608
checkLeader(scatterer.ordinaryEngine.selectedLeader)
609609
}
610610

611-
// TestSelectedStores tests if the peer count has changed due to the picking strategy.
611+
// TestSelectedStoresTooFewPeers tests if the peer count has changed due to the picking strategy.
612612
// Ref https://github.com/tikv/pd/issues/4565
613613
func (s *testScatterRegionSuite) TestSelectedStores(c *C) {
614614
ctx, cancel := context.WithCancel(context.Background())
@@ -644,6 +644,43 @@ func (s *testScatterRegionSuite) TestSelectedStores(c *C) {
644644
}
645645
}
646646

647+
// TestSelectedStoresTooManyPeers tests if the peer count has changed due to the picking strategy.
648+
// Ref https://github.com/tikv/pd/issues/5909
649+
func TestSelectedStoresTooManyPeers(t *testing.T) {
650+
re := require.New(t)
651+
ctx, cancel := context.WithCancel(context.Background())
652+
defer cancel()
653+
opt := config.NewTestOptions()
654+
tc := mockcluster.NewCluster(ctx, opt)
655+
stream := hbstream.NewTestHeartbeatStreams(ctx, tc.ID, tc, false)
656+
oc := NewOperatorController(ctx, tc, stream)
657+
// Add 4 stores.
658+
for i := uint64(1); i <= 5; i++ {
659+
tc.AddRegionStore(i, 0)
660+
// prevent store from being disconnected
661+
tc.SetStoreLastHeartbeatInterval(i, -10*time.Minute)
662+
}
663+
group := "group"
664+
scatterer := NewRegionScatterer(ctx, tc, oc)
665+
// priority 4 > 1 > 5 > 2 == 3
666+
for i := 0; i < 1200; i++ {
667+
scatterer.ordinaryEngine.selectedPeer.Put(2, group)
668+
scatterer.ordinaryEngine.selectedPeer.Put(3, group)
669+
}
670+
for i := 0; i < 800; i++ {
671+
scatterer.ordinaryEngine.selectedPeer.Put(5, group)
672+
}
673+
for i := 0; i < 400; i++ {
674+
scatterer.ordinaryEngine.selectedPeer.Put(1, group)
675+
}
676+
// test region with peer 1 2 3
677+
for i := uint64(1); i < 20; i++ {
678+
region := tc.AddLeaderRegion(i+200, i%3+1, (i+1)%3+1, (i+2)%3+1)
679+
op := scatterer.scatterRegion(region, group)
680+
re.False(isPeerCountChanged(op))
681+
}
682+
}
683+
647684
// TestBalanceRegion tests whether region peers and leaders are balanced after scatter.
648685
// ref https://github.com/tikv/pd/issues/6017
649686
func TestBalanceRegion(t *testing.T) {

0 commit comments

Comments
 (0)