Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
close #4090

Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Nov 30, 2021
1 parent d88b847 commit eaed852
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 87 deletions.
15 changes: 13 additions & 2 deletions server/cluster/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1047,14 +1047,25 @@ func (s *testOperatorControllerSuite) TestDownStoreLimit(c *C) {
region := tc.GetRegion(1)
tc.setStoreDown(1)
tc.SetStoreLimit(1, storelimit.RemovePeer, 1)

region = region.Clone(core.WithDownPeers([]*pdpb.PeerStats{
{
Peer: region.GetStorePeer(1),
DownSeconds: 24 * 60 * 60,
},
}))
}), core.SetApproximateSize(1))
tc.putRegion(region)
for i := uint64(1); i < 20; i++ {
tc.addRegionStore(i+3, 100)
op := rc.Check(region)
c.Assert(op, NotNil)
c.Assert(oc.AddOperator(op), IsTrue)
oc.RemoveOperator(op)
}

for i := uint64(1); i <= 5; i++ {
region = region.Clone(core.SetApproximateSize(100))
tc.putRegion(region)
for i := uint64(20); i < 25; i++ {
tc.addRegionStore(i+3, 100)
op := rc.Check(region)
c.Assert(op, NotNil)
Expand Down
81 changes: 0 additions & 81 deletions server/schedule/checker/rule_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
package checker

import (
<<<<<<< HEAD
"encoding/hex"
=======
"context"
>>>>>>> 1a7caa95c (schedule: not limit remove peer of the down store (#4097))

. "github.com/pingcap/check"
"github.com/pingcap/kvproto/pkg/metapb"
Expand Down Expand Up @@ -576,83 +572,6 @@ func (s *testRuleCheckerSuite) TestFixOfflinePeer(c *C) {
c.Assert(s.rc.Check(region), IsNil)
}

<<<<<<< HEAD
=======
func (s *testRuleCheckerSerialSuite) TestRuleCache(c *C) {
s.cluster.AddLabelsStore(1, 1, map[string]string{"zone": "z1"})
s.cluster.AddLabelsStore(2, 1, map[string]string{"zone": "z1"})
s.cluster.AddLabelsStore(3, 1, map[string]string{"zone": "z2"})
s.cluster.AddLabelsStore(4, 1, map[string]string{"zone": "z3"})
s.cluster.AddLabelsStore(5, 1, map[string]string{"zone": "z3"})
s.cluster.AddRegionStore(999, 1)
s.cluster.AddLeaderRegion(1, 1, 3, 4)
rule := &placement.Rule{
GroupID: "pd",
ID: "test",
Index: 100,
Override: true,
Role: placement.Voter,
Count: 3,
LocationLabels: []string{"zone"},
}
s.ruleManager.SetRule(rule)
region := s.cluster.GetRegion(1)
region = region.Clone(core.WithIncConfVer(), core.WithIncVersion())
c.Assert(s.rc.Check(region), IsNil)

testcases := []struct {
name string
region *core.RegionInfo
stillCached bool
}{
{
name: "default",
region: region,
stillCached: true,
},
{
name: "region topo changed",
region: func() *core.RegionInfo {
return region.Clone(core.WithAddPeer(&metapb.Peer{
Id: 999,
StoreId: 999,
Role: metapb.PeerRole_Voter,
}), core.WithIncConfVer())
}(),
stillCached: false,
},
{
name: "region leader changed",
region: region.Clone(
core.WithLeader(&metapb.Peer{Role: metapb.PeerRole_Voter, Id: 2, StoreId: 3})),
stillCached: false,
},
{
name: "region have down peers",
region: region.Clone(core.WithDownPeers([]*pdpb.PeerStats{
{
Peer: region.GetPeer(3),
DownSeconds: 42,
},
})),
stillCached: false,
},
}
for _, testcase := range testcases {
c.Log(testcase.name)
if testcase.stillCached {
c.Assert(failpoint.Enable("github.com/tikv/pd/server/schedule/checker/assertShouldCache", "return(true)"), IsNil)
s.rc.Check(testcase.region)
c.Assert(failpoint.Disable("github.com/tikv/pd/server/schedule/checker/assertShouldCache"), IsNil)
} else {
c.Assert(failpoint.Enable("github.com/tikv/pd/server/schedule/checker/assertShouldNotCache", "return(true)"), IsNil)
s.rc.Check(testcase.region)
c.Assert(failpoint.Disable("github.com/tikv/pd/server/schedule/checker/assertShouldNotCache"), IsNil)
}
}
}

>>>>>>> 1a7caa95c (schedule: not limit remove peer of the down store (#4097))
// Ref https://github.com/tikv/pd/issues/4045
func (s *testRuleCheckerSuite) TestSkipFixOrphanPeerIfSelectedPeerisPendingOrDown(c *C) {
s.cluster.AddLabelsStore(1, 1, map[string]string{"host": "host1"})
Expand Down
2 changes: 1 addition & 1 deletion server/schedule/operator/influence.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (s *StoreInfluence) addStepCost(limitType storelimit.Type, cost int64) {
func (s *StoreInfluence) AdjustStepCost(limitType storelimit.Type, regionSize int64) {
if regionSize > storelimit.SmallRegionThreshold {
s.addStepCost(limitType, storelimit.RegionInfluence[limitType])
} else if regionSize <= storelimit.SmallRegionThreshold && regionSize > core.EmptyRegionApproximateSize {
} else if regionSize > core.EmptyRegionApproximateSize {
s.addStepCost(limitType, storelimit.SmallRegionInfluence[limitType])
}
}
6 changes: 3 additions & 3 deletions server/schedule/operator/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ func (rp RemovePeer) Influence(opInfluence OpInfluence, region *core.RegionInfo)
regionSize := region.GetApproximateSize()
from.RegionSize -= regionSize
from.RegionCount--
if rp.IsDownStore {
from.AdjustStepCost(storelimit.RemovePeer, storelimit.SmallRegionThreshold)
return

if rp.IsDownStore && regionSize > storelimit.SmallRegionThreshold {
regionSize = storelimit.SmallRegionThreshold
}
from.AdjustStepCost(storelimit.RemovePeer, regionSize)
}
Expand Down

0 comments on commit eaed852

Please sign in to comment.