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

slow node detection: enable evict-slow-trend on raft-kv2. #6945

Merged
merged 24 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dee81e5
slow node detection: enable `evict-slow-trend` on `raft-kv2`.
LykxSassinator Aug 10, 2023
32b968b
Merge branch 'master' into enable-slow-trend-v2
LykxSassinator Aug 10, 2023
eea16e1
Bugfix as interface changed.
LykxSassinator Aug 10, 2023
dfc822e
Fix the error in ut.
LykxSassinator Aug 10, 2023
7a6e632
Merge branch 'master' into enable-slow-trend-v2
LykxSassinator Aug 10, 2023
4ad65ff
Supply extra uts to improve the testing coverage.
LykxSassinator Aug 11, 2023
4b14638
Merge branch 'master' into enable-slow-trend-v2
LykxSassinator Aug 14, 2023
793abac
Merge branch 'master' into enable-slow-trend-v2
LykxSassinator Aug 14, 2023
665b636
Merge branch 'master' into enable-slow-trend-v2
LykxSassinator Aug 15, 2023
368dfd3
Merge branch 'master' into enable-slow-trend-v2
LykxSassinator Aug 16, 2023
e7e8449
Polish codes.
LykxSassinator Aug 16, 2023
f77dd9d
Polish metrics.
LykxSassinator Aug 16, 2023
165517c
Bugfix for metrics
LykxSassinator Aug 16, 2023
d443257
Polish the codes.
LykxSassinator Aug 21, 2023
815d2ee
Polish codes.
LykxSassinator Aug 22, 2023
1830001
Merge branch 'master' into enable-slow-trend-v2
LykxSassinator Aug 22, 2023
2cf4430
Polish codes.
LykxSassinator Aug 22, 2023
880e9f5
Bugfix for uts.
LykxSassinator Aug 22, 2023
f0a0ec8
Polish codes.
LykxSassinator Aug 22, 2023
65e7c26
Bugfix for starting the coordinator.
LykxSassinator Aug 23, 2023
e83599c
Bugfix when starting the cluster with raft-kv2
LykxSassinator Aug 23, 2023
f157789
Merge branch 'master' into enable-slow-trend-v2
LykxSassinator Aug 23, 2023
566c248
Merge branch 'master' into enable-slow-trend-v2
LykxSassinator Aug 23, 2023
b29d736
Replace failpoint with testing.Testing() to polish codes.
LykxSassinator Aug 23, 2023
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
10 changes: 10 additions & 0 deletions pkg/mcs/scheduling/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,21 @@ func (o *PersistConfig) GetRegionMaxKeys() uint64 {
return o.GetStoreConfig().GetRegionMaxKeys()
}

// IsSynced returns true if the cluster config is synced.
func (o *PersistConfig) IsSynced() bool {
return o.GetStoreConfig().IsSynced()
}

// IsEnableRegionBucket return true if the region bucket is enabled.
func (o *PersistConfig) IsEnableRegionBucket() bool {
return o.GetStoreConfig().IsEnableRegionBucket()
}

// IsRaftKV2 returns the whether the cluster use `raft-kv2` engine.
func (o *PersistConfig) IsRaftKV2() bool {
return o.GetStoreConfig().IsRaftKV2()
}

// TODO: implement the following methods

// AddSchedulerCfg adds the scheduler configurations.
Expand Down
2 changes: 2 additions & 0 deletions pkg/schedule/config/config_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,7 @@ type StoreConfigProvider interface {
GetRegionMaxKeys() uint64
CheckRegionSize(uint64, uint64) error
CheckRegionKeys(uint64, uint64) error
IsSynced() bool
IsEnableRegionBucket() bool
IsRaftKV2() bool
}
18 changes: 18 additions & 0 deletions pkg/schedule/config/store_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
RegionMaxSizeMB uint64 `json:"-"`
RegionSplitSizeMB uint64 `json:"-"`
RegionBucketSizeMB uint64 `json:"-"`

Sync bool `json:"sync"`
}

// Storage is the config for the tikv storage.
Expand All @@ -73,6 +75,7 @@
if c == nil {
return
}

c.RegionMaxSizeMB = typeutil.ParseMBFromText(c.RegionMaxSize, defaultRegionMaxSize)
c.RegionSplitSizeMB = typeutil.ParseMBFromText(c.RegionSplitSize, defaultRegionSplitSize)
c.RegionBucketSizeMB = typeutil.ParseMBFromText(c.RegionBucketSize, defaultBucketSize)
Expand Down Expand Up @@ -124,6 +127,21 @@
return uint64(c.RegionMaxKeys)
}

// SetSynced marks StoreConfig has been synced.
func (c *StoreConfig) SetSynced() {
if c != nil {
c.Sync = true
}
}

// IsSynced returns whether the StoreConfig is synced or not.
func (c *StoreConfig) IsSynced() bool {
if c == nil {
return false

Check warning on line 140 in pkg/schedule/config/store_config.go

View check run for this annotation

Codecov / codecov/patch

pkg/schedule/config/store_config.go#L140

Added line #L140 was not covered by tests
}
return c.Sync
}

// IsEnableRegionBucket return true if the region bucket is enabled.
func (c *StoreConfig) IsEnableRegionBucket() bool {
if c == nil {
Expand Down
22 changes: 20 additions & 2 deletions pkg/schedule/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"context"
"strconv"
"sync"
"testing"
"time"

"github.com/pingcap/errors"
Expand Down Expand Up @@ -375,7 +376,6 @@
if err != nil {
log.Fatal("cannot load schedulers' config", errs.ZapError(err))
}

scheduleCfg := c.cluster.GetSchedulerConfig().GetScheduleConfig().Clone()
// The new way to create scheduler with the independent configuration.
for i, name := range scheduleNames {
Expand Down Expand Up @@ -439,6 +439,20 @@
if err := c.cluster.GetSchedulerConfig().Persist(c.cluster.GetStorage()); err != nil {
log.Error("cannot persist schedule config", errs.ZapError(err))
}

// If the cluster was set up with `raft-kv2` engine, this cluster should
// enable `evict-slow-trend` scheduler as default.
if c.GetCluster().GetStoreConfig().IsRaftKV2() {
name := schedulers.EvictSlowTrendType
args := []string{}

s, err := schedulers.CreateScheduler(name, c.opController, c.cluster.GetStorage(), schedulers.ConfigSliceDecoder(name, args), c.schedulers.RemoveScheduler)
if err != nil {
log.Warn("initializing evict-slow-trend scheduler failed", errs.ZapError(err))

Check warning on line 451 in pkg/schedule/coordinator.go

View check run for this annotation

Codecov / codecov/patch

pkg/schedule/coordinator.go#L451

Added line #L451 was not covered by tests
} else if err = c.schedulers.AddScheduler(s, args...); err != nil {
log.Error("can not add scheduler", zap.String("scheduler-name", s.GetName()), zap.Strings("scheduler-args", args), errs.ZapError(err))

Check warning on line 453 in pkg/schedule/coordinator.go

View check run for this annotation

Codecov / codecov/patch

pkg/schedule/coordinator.go#L453

Added line #L453 was not covered by tests
}
}
}

// LoadPlugin load user plugin
Expand Down Expand Up @@ -625,7 +639,11 @@

// ShouldRun returns true if the coordinator should run.
func (c *Coordinator) ShouldRun() bool {
return c.prepareChecker.check(c.cluster.GetBasicCluster())
isSynced := c.cluster.GetStoreConfig().IsSynced()
if testing.Testing() {
isSynced = true
}
return c.prepareChecker.check(c.cluster.GetBasicCluster()) && isSynced
}

// GetSchedulersController returns the schedulers controller.
Expand Down
Loading
Loading