Skip to content

Commit

Permalink
fix race
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Nov 7, 2023
1 parent be68446 commit 2d6d331
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/schedule/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ func (c *Coordinator) RunUntilStop() {
c.Run()
<-c.ctx.Done()
log.Info("coordinator is stopping")
c.GetSchedulersController().Wait()
c.wg.Wait()
log.Info("coordinator has been stopped")
}

// Run starts coordinator.
Expand Down Expand Up @@ -576,9 +579,6 @@ func (c *Coordinator) waitPluginUnload(pluginPath, schedulerName string, ch chan
// Stop stops the coordinator.
func (c *Coordinator) Stop() {
c.cancel()
c.GetSchedulersController().Wait()
c.wg.Wait()
log.Info("coordinator has been stopped")
}

// GetHotRegionsByType gets hot regions' statistics by RWType.
Expand Down
2 changes: 1 addition & 1 deletion server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ func (c *RaftCluster) Stop() {
return
}
c.running = false
if !c.IsServiceEnabled(mcsutils.SchedulingServiceName) {
if !c.IsServiceEnabled(mcsutils.SchedulingServiceName) && c.schedulingController.running.Load() {
c.stopSchedulingJobs()
}
c.cancel()
Expand Down

0 comments on commit 2d6d331

Please sign in to comment.