diff --git a/pkg/schedule/coordinator.go b/pkg/schedule/coordinator.go index bf5a2d8ce7c..3708acf12a7 100644 --- a/pkg/schedule/coordinator.go +++ b/pkg/schedule/coordinator.go @@ -239,6 +239,7 @@ func (c *Coordinator) startPatrolRegionWorkers(workers int, regionChan <-chan *c go func() { defer wg.Done() for { + patrolCheckRegionsChanLenGauge.Set(float64(len(regionChan))) select { case region, ok := <-regionChan: if ok { @@ -255,7 +256,6 @@ func (c *Coordinator) startPatrolRegionWorkers(workers int, regionChan <-chan *c // waitDrainRegionChan is used to drain the regionChan. // It is used to avoid duplicated regions in the regionChan from different sources. func (c *Coordinator) waitDrainRegionChan(regionChan chan *core.RegionInfo) { - patrolCheckRegionsChanLenGauge.Set(float64(len(regionChan))) if len(regionChan) == 0 { return }