-
Notifications
You must be signed in to change notification settings - Fork 725
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
*: reset prepare checker once the cache is reset #8860
Open
rleungx
wants to merge
18
commits into
tikv:master
Choose a base branch
from
rleungx:reset-prepared
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+186
−83
Open
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d0aff18
reset prepare checker once the cache is reset
rleungx 76b797d
fix
rleungx be95f0c
move prepare checker
rleungx 878f9de
add test
rleungx 11f48c7
fix
rleungx 7c9986b
fix
rleungx 1c28cbd
fix
rleungx 69886b1
fix
rleungx b46fbe3
fix
rleungx ab7cc56
fix
rleungx a53e150
fix
rleungx 0bc6e36
fix
rleungx ad5fe05
fix
rleungx 39ae987
fix
rleungx 7c2ef71
fix
rleungx d21caa3
cleanup
rleungx a639570
fix
rleungx 71fefc1
fix
rleungx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,6 @@ import ( | |
|
||
const ( | ||
runSchedulerCheckInterval = 3 * time.Second | ||
collectTimeout = 5 * time.Minute | ||
maxLoadConfigRetries = 10 | ||
// pushOperatorTickInterval is the interval try to push the operator. | ||
pushOperatorTickInterval = 500 * time.Millisecond | ||
|
@@ -66,7 +65,7 @@ type Coordinator struct { | |
schedulersInitialized bool | ||
|
||
cluster sche.ClusterInformer | ||
prepareChecker *prepareChecker | ||
prepareChecker *sche.PrepareChecker | ||
checkers *checker.Controller | ||
regionScatterer *scatter.RegionScatterer | ||
regionSplitter *splitter.RegionSplitter | ||
|
@@ -80,15 +79,16 @@ type Coordinator struct { | |
// NewCoordinator creates a new Coordinator. | ||
func NewCoordinator(parentCtx context.Context, cluster sche.ClusterInformer, hbStreams *hbstream.HeartbeatStreams) *Coordinator { | ||
ctx, cancel := context.WithCancel(parentCtx) | ||
prepareChecker := sche.NewPrepareChecker() | ||
opController := operator.NewController(ctx, cluster.GetBasicCluster(), cluster.GetSharedConfig(), hbStreams) | ||
schedulers := schedulers.NewController(ctx, cluster, cluster.GetStorage(), opController) | ||
checkers := checker.NewController(ctx, cluster, cluster.GetCheckerConfig(), cluster.GetRuleManager(), cluster.GetRegionLabeler(), opController) | ||
schedulers := schedulers.NewController(ctx, cluster, cluster.GetStorage(), opController, prepareChecker) | ||
checkers := checker.NewController(ctx, cluster, cluster.GetCheckerConfig(), cluster.GetRuleManager(), cluster.GetRegionLabeler(), opController, prepareChecker) | ||
return &Coordinator{ | ||
ctx: ctx, | ||
cancel: cancel, | ||
schedulersInitialized: false, | ||
cluster: cluster, | ||
prepareChecker: newPrepareChecker(), | ||
prepareChecker: prepareChecker, | ||
checkers: checkers, | ||
regionScatterer: scatter.NewRegionScatterer(ctx, cluster, opController, checkers.AddPendingProcessedRegions), | ||
regionSplitter: splitter.NewRegionSplitter(cluster, splitter.NewSplitRegionsHandler(cluster, opController), checkers.AddPendingProcessedRegions), | ||
|
@@ -204,8 +204,8 @@ func (c *Coordinator) driveSlowNodeScheduler() { | |
} | ||
|
||
// RunUntilStop runs the coordinator until receiving the stop signal. | ||
func (c *Coordinator) RunUntilStop(collectWaitTime ...time.Duration) { | ||
c.Run(collectWaitTime...) | ||
func (c *Coordinator) RunUntilStop() { | ||
c.Run() | ||
<-c.ctx.Done() | ||
log.Info("coordinator is stopping") | ||
c.GetSchedulersController().Wait() | ||
|
@@ -214,25 +214,12 @@ func (c *Coordinator) RunUntilStop(collectWaitTime ...time.Duration) { | |
} | ||
|
||
// Run starts coordinator. | ||
func (c *Coordinator) Run(collectWaitTime ...time.Duration) { | ||
func (c *Coordinator) Run() { | ||
ticker := time.NewTicker(runSchedulerCheckInterval) | ||
failpoint.Inject("changeCoordinatorTicker", func() { | ||
ticker.Reset(100 * time.Millisecond) | ||
}) | ||
defer ticker.Stop() | ||
log.Info("coordinator starts to collect cluster information") | ||
for { | ||
if c.ShouldRun(collectWaitTime...) { | ||
log.Info("coordinator has finished cluster information preparation") | ||
break | ||
} | ||
select { | ||
case <-ticker.C: | ||
case <-c.ctx.Done(): | ||
log.Info("coordinator stops running") | ||
return | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need the similar log? |
||
} | ||
log.Info("coordinator starts to run schedulers") | ||
c.InitSchedulers(true) | ||
|
||
|
@@ -547,8 +534,8 @@ func ResetHotSpotMetrics() { | |
} | ||
|
||
// ShouldRun returns true if the coordinator should run. | ||
func (c *Coordinator) ShouldRun(collectWaitTime ...time.Duration) bool { | ||
return c.prepareChecker.check(c.cluster.GetBasicCluster(), collectWaitTime...) | ||
func (c *Coordinator) ShouldRun() bool { | ||
return c.prepareChecker.Check(c.cluster.GetBasicCluster()) | ||
} | ||
|
||
// GetSchedulersController returns the schedulers controller. | ||
|
@@ -616,7 +603,7 @@ func (c *Coordinator) GetRuleChecker() *checker.RuleChecker { | |
} | ||
|
||
// GetPrepareChecker returns the prepare checker. | ||
func (c *Coordinator) GetPrepareChecker() *prepareChecker { | ||
func (c *Coordinator) GetPrepareChecker() *sche.PrepareChecker { | ||
return c.prepareChecker | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, this function has too many parameters. Do we have any good way to solve it?