Skip to content

Commit

Permalink
speed schedule exit
Browse files Browse the repository at this point in the history
Signed-off-by: bufferflies <1045931706@qq.com>
  • Loading branch information
bufferflies committed Sep 26, 2021
1 parent cf1f2a0 commit 1ee33b4
Show file tree
Hide file tree
Showing 2 changed files with 6 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 @@ -391,8 +391,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
5 changes: 5 additions & 0 deletions server/cluster/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,11 @@ func (s *scheduleController) Stop() {

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

0 comments on commit 1ee33b4

Please sign in to comment.