Skip to content

Commit

Permalink
Merge branch 'release-4.0' into release-4.0-66c26169b813
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch authored Jan 26, 2021
2 parents cd5ebe1 + c8a4625 commit dcd6804
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/opentracing/opentracing-go v1.1.0
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d
github.com/pingcap-incubator/tidb-dashboard v0.0.0-20201126111827-6c8be2240067
github.com/pingcap-incubator/tidb-dashboard v0.0.0-20210104140916-41a0a3a87e75
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712
github.com/pingcap/errcode v0.3.0
github.com/pingcap/errors v0.11.5-0.20201126102027-b0a155152ca3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d h1:U+PMnTlV2tu7RuMK5etusZG3Cf+rpow5hqQByeCzJ2g=
github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d/go.mod h1:lXfE4PvvTW5xOjO6Mba8zDPyw8M93B6AQ7frTGnMlA8=
github.com/pingcap-incubator/tidb-dashboard v0.0.0-20201126111827-6c8be2240067 h1:hq1pTBUxx0Szt6vyM++KQR+kmxhTPDC5csJPRkQzxO8=
github.com/pingcap-incubator/tidb-dashboard v0.0.0-20201126111827-6c8be2240067/go.mod h1:EONGys2gM5n14pII2vjmU/5VG3Dtj6kpqUT1GUZ4ysw=
github.com/pingcap-incubator/tidb-dashboard v0.0.0-20210104140916-41a0a3a87e75 h1:XJ/OVqPtHuGNLgCu6xgSlCouz5roe3Yf3TXHjVNf+9w=
github.com/pingcap-incubator/tidb-dashboard v0.0.0-20210104140916-41a0a3a87e75/go.mod h1:EONGys2gM5n14pII2vjmU/5VG3Dtj6kpqUT1GUZ4ysw=
github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8/go.mod h1:B1+S9LNcuMyLH/4HMTViQOJevkGiik3wW2AN9zb2fNQ=
github.com/pingcap/check v0.0.0-20191107115940-caf2b9e6ccf4/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc=
github.com/pingcap/check v0.0.0-20191216031241-8a5a85928f12/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc=
Expand Down
7 changes: 7 additions & 0 deletions server/schedule/checker/merge_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"github.com/tikv/pd/server/schedule/placement"
)

const maxTargetRegionSize = 500

// MergeChecker ensures region to merge with adjacent region when size is small
type MergeChecker struct {
cluster opt.Cluster
Expand Down Expand Up @@ -119,6 +121,11 @@ func (m *MergeChecker) Check(region *core.RegionInfo) []*operator.Operator {
return nil
}

if target.GetApproximateSize() > maxTargetRegionSize {
checkerCounter.WithLabelValues("merge_checker", "target-too-large").Inc()
return nil
}

log.Debug("try to merge region",
logutil.ZapRedactStringer("from", core.RegionToHexMeta(region.GetMeta())),
logutil.ZapRedactStringer("to", core.RegionToHexMeta(target.GetMeta())))
Expand Down
6 changes: 6 additions & 0 deletions server/schedule/checker/merge_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ func (s *testMergeCheckerSuite) TestBasic(c *C) {
// The size should be small enough.
ops = s.mc.Check(s.regions[1])
c.Assert(ops, IsNil)
// target region size is too large
s.cluster.PutRegion(s.regions[1].Clone(core.SetApproximateSize(600)))
ops = s.mc.Check(s.regions[2])
c.Assert(ops, IsNil)
// change the size back
s.cluster.PutRegion(s.regions[1].Clone(core.SetApproximateSize(200)))
ops = s.mc.Check(s.regions[2])
c.Assert(ops, NotNil)
// Check merge with previous region.
Expand Down

0 comments on commit dcd6804

Please sign in to comment.