Skip to content

Commit

Permalink
set MaxScheduleCost to 0 by default
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Apr 2, 2019
1 parent 8624ddf commit 2a41999
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
12 changes: 6 additions & 6 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,14 @@ const (
defaultMaxMergeRegionKeys = 200000
defaultSplitMergeInterval = 1 * time.Hour
defaultPatrolRegionInterval = 100 * time.Millisecond
defaultMaxStoreDownTime = 30 * time.Minute
defaultLeaderScheduleLimit = 4
defaultRegionScheduleLimit = 4
defaultReplicaScheduleLimit = 8
defaultMaxStoreDownTime = 30 * time.Second
defaultLeaderScheduleLimit = 1000
defaultRegionScheduleLimit = 1000
defaultReplicaScheduleLimit = 1000
defaultMergeScheduleLimit = 8
defaultHotRegionScheduleLimit = 2
defaultMaxScheduleCost = 200
defaultStoreMaxScheduleCost = 20
defaultMaxScheduleCost = 0
defaultStoreMaxScheduleCost = 50
defaultTolerantSizeRatio = 5
defaultLowSpaceRatio = 0.8
defaultHighSpaceRatio = 0.6
Expand Down
6 changes: 4 additions & 2 deletions server/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func (c *coordinator) checkRegion(region *core.RegionInfo) bool {
// If PD has restarted, it need to check learners added before and promote them.
// Don't check isRaftLearnerEnabled cause it maybe disable learner feature but there are still some learners to promote.
opController := c.opController
if c.opController.GetScheduleCost() >= c.cluster.GetMaxScheduleCost() {
maxScheduleCost := c.cluster.GetMaxScheduleCost()
if maxScheduleCost != 0 && c.opController.GetScheduleCost() >= maxScheduleCost {
return false
}
for _, p := range region.GetLearners() {
Expand Down Expand Up @@ -472,7 +473,8 @@ func (s *scheduleController) GetInterval() time.Duration {

// AllowSchedule returns if a scheduler is allowed to schedule.
func (s *scheduleController) AllowSchedule() bool {
if s.opController.GetScheduleCost() >= s.cluster.GetMaxScheduleCost() {
maxScheduleCost := s.cluster.GetMaxScheduleCost()
if maxScheduleCost != 0 && s.opController.GetScheduleCost() >= maxScheduleCost {
return false
}
return s.Scheduler.IsScheduleAllowed(s.cluster)
Expand Down
4 changes: 2 additions & 2 deletions server/schedule/mockcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ const (
defaultReplicaScheduleLimit = 8
defaultMergeScheduleLimit = 8
defaultHotRegionScheduleLimit = 2
defaultMaxScheduleCost = 200
defaultStoreMaxScheduleCost = 20
defaultMaxScheduleCost = 0
defaultStoreMaxScheduleCost = 50
defaultTolerantSizeRatio = 2.5
defaultLowSpaceRatio = 0.8
defaultHighSpaceRatio = 0.6
Expand Down
2 changes: 1 addition & 1 deletion server/schedule/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
// longer than it, the operator will be considered timeout.
RegionOperatorWaitTime = 10 * time.Minute
// RegionWeight reflects the influence which is caused by a region related step in an operator.
RegionWeight = 2
RegionWeight = 10
// LeaderWeight reflects the influence which is caused by a leader related step in an operator.
LeaderWeight = 1
)
Expand Down
2 changes: 2 additions & 0 deletions tools/pd-simulator/simulator/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ func (r *RaftEngine) NeedSplit(size, rows int64) bool {
}

func (r *RaftEngine) recordRegionChange(region *core.RegionInfo) {
r.Lock()
defer r.Unlock()
n := region.GetLeader().GetStoreId()
r.regionChange[n] = append(r.regionChange[n], region.GetID())
}
Expand Down
5 changes: 0 additions & 5 deletions tools/pd-simulator/simulator/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ import (
"bytes"
"fmt"

"go.uber.org/zap"

"github.com/pingcap/kvproto/pkg/eraftpb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/pd/server/core"
"github.com/pingcap/pd/tools/pd-simulator/simulator/simutil"
)

// Task running in node.
Expand Down Expand Up @@ -234,7 +231,6 @@ func (a *addPeer) Step(r *RaftEngine) {
snapshotSize := region.GetApproximateSize()
sendNode := r.conn.Nodes[region.GetLeader().GetStoreId()]
if sendNode == nil {
simutil.Logger.Error("failed to sent snapshot, node has been deleted", zap.Uint64("node-id", sendNode.Id))
a.finished = true
return
}
Expand All @@ -245,7 +241,6 @@ func (a *addPeer) Step(r *RaftEngine) {

recvNode := r.conn.Nodes[a.peer.GetStoreId()]
if recvNode == nil {
simutil.Logger.Error("failed to receive snapshot: node has been deleted", zap.Uint64("node-id", recvNode.Id))
a.finished = true
return
}
Expand Down

0 comments on commit 2a41999

Please sign in to comment.