Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checker: fix the issue that a region does not merge to the sibling with smaller size (#1723) #1726

Merged
merged 1 commit into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions server/schedule/merge_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,9 @@ func (m *MergeChecker) Check(region *core.RegionInfo) []*Operator {

prev, next := m.cluster.GetAdjacentRegions(region)

var target *core.RegionInfo
targetNext := m.checkTarget(region, next, target)
target = m.checkTarget(region, prev, target)
if target != targetNext && m.cluster.GetEnableOneWayMerge() {
checkerCounter.WithLabelValues("merge_checker", "skip_left").Inc()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, do we need to keep the metrics?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

em, seems not very useful

target = targetNext
target := m.checkTarget(region, next, nil)
if !m.cluster.GetEnableOneWayMerge() {
target = m.checkTarget(region, prev, target)
}

if target == nil {
Expand Down
12 changes: 12 additions & 0 deletions server/schedule/merge_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,25 @@ func (s *testMergeCheckerSuite) TestBasic(c *C) {
op.startTime = op.startTime.Add(-RegionOperatorWaitTime - time.Second)
c.Assert(op.IsTimeout(), IsTrue)
}
// Check merge with previous region.
c.Assert(ops[0].RegionID(), Equals, s.regions[2].GetID())
c.Assert(ops[1].RegionID(), Equals, s.regions[1].GetID())

// Enable one way merge
s.cluster.EnableOneWayMerge = true
ops = s.mc.Check(s.regions[2])
c.Assert(ops, IsNil)
s.cluster.EnableOneWayMerge = false

// Make up peers for next region.
s.regions[3] = s.regions[3].Clone(core.WithAddPeer(&metapb.Peer{Id: 110, StoreId: 1}), core.WithAddPeer(&metapb.Peer{Id: 111, StoreId: 2}))
s.cluster.PutRegion(s.regions[3])
ops = s.mc.Check(s.regions[2])
c.Assert(ops, NotNil)
// Now it merges to next region.
c.Assert(ops[0].RegionID(), Equals, s.regions[2].GetID())
c.Assert(ops[1].RegionID(), Equals, s.regions[3].GetID())

// Skip recently split regions.
s.mc.RecordRegionSplit(s.regions[2].GetID())
ops = s.mc.Check(s.regions[2])
Expand Down