Skip to content

Commit

Permalink
cluster: speed scheduler exit (#4148) (#4198)
Browse files Browse the repository at this point in the history
* This is an automated cherry-pick of #4148

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
ti-chi-bot committed Nov 30, 2021
1 parent 6b186ae commit dcfbff7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ func (c *RaftCluster) Stop() {
}

c.running = false
close(c.quit)
c.coordinator.stop()
close(c.quit)
c.Unlock()
c.wg.Wait()
log.Info("raftcluster is stopped")
Expand Down
6 changes: 6 additions & 0 deletions server/cluster/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,12 @@ func (s *scheduleController) Stop() {

func (s *scheduleController) Schedule() []*operator.Operator {
for i := 0; i < maxScheduleRetries; i++ {
// no need to retry if schedule should stop to speed exit
select {
case <-s.ctx.Done():
return nil
default:
}
// If we have schedule, reset interval to the minimal interval.
if op := s.Scheduler.Schedule(s.cluster); op != nil {
s.nextInterval = s.Scheduler.GetMinInterval()
Expand Down

0 comments on commit dcfbff7

Please sign in to comment.