diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index f769d752660..34453b8b5ba 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -383,8 +383,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") diff --git a/server/cluster/coordinator.go b/server/cluster/coordinator.go index 6bfd68a88d2..ecb5506ce9d 100644 --- a/server/cluster/coordinator.go +++ b/server/cluster/coordinator.go @@ -822,6 +822,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()