Skip to content

Commit

Permalink
checker: prevent the regions in split-cache from becoming the target …
Browse files Browse the repository at this point in the history
…of merge (tikv#3454) (tikv#3458)

* cherry pick tikv#3454 to release-3.0

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* revert

Signed-off-by: HunDunDM <hundundm@gmail.com>

* pick

Signed-off-by: HunDunDM <hundundm@gmail.com>

Co-authored-by: 混沌DM <hundundm@gmail.com>
Co-authored-by: Ti Chi Robot <71242396+ti-chi-bot@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 11, 2021
1 parent 635fef2 commit 669ecba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/schedule/merge_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (m *MergeChecker) Check(region *core.RegionInfo) []*Operator {

func (m *MergeChecker) checkTarget(region, adjacent, target *core.RegionInfo) *core.RegionInfo {
// if is not hot region and under same namespace
if adjacent != nil && !m.cluster.IsRegionHot(adjacent.GetID()) &&
if adjacent != nil && !m.splitCache.Exists(adjacent.GetID()) && !m.cluster.IsRegionHot(adjacent.GetID()) &&
m.classifier.AllowMerge(region, adjacent) &&
len(adjacent.GetDownPeers()) == 0 && len(adjacent.GetPendingPeers()) == 0 && len(adjacent.GetLearners()) == 0 {
// if both region is not hot, prefer the one with smaller size
Expand Down
9 changes: 7 additions & 2 deletions server/schedule/merge_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func (s *testMergeCheckerSuite) SetUpTest(c *C) {
},
},
&metapb.Peer{Id: 109, StoreId: 4},
core.SetApproximateSize(10),
core.SetApproximateKeys(10),
core.SetApproximateSize(1),
core.SetApproximateKeys(1),
),
}

Expand Down Expand Up @@ -148,6 +148,11 @@ func (s *testMergeCheckerSuite) TestBasic(c *C) {
c.Assert(ops[1].RegionID(), Equals, s.regions[3].GetID())

// Skip recently split regions.
ops = s.mc.Check(s.regions[2])
c.Assert(ops, NotNil)
ops = s.mc.Check(s.regions[3])
c.Assert(ops, NotNil)

s.mc.RecordRegionSplit(s.regions[2].GetID())
ops = s.mc.Check(s.regions[2])
c.Assert(ops, IsNil)
Expand Down

0 comments on commit 669ecba

Please sign in to comment.