From aa544294fb377d2935e22634e530d59b0aaea29b Mon Sep 17 00:00:00 2001 From: nolouch Date: Thu, 18 Apr 2024 21:12:54 +0800 Subject: [PATCH] schedule: fix the metrics flush Signed-off-by: nolouch --- pkg/schedule/schedulers/balance_leader.go | 2 +- pkg/schedule/schedulers/balance_region.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/schedule/schedulers/balance_leader.go b/pkg/schedule/schedulers/balance_leader.go index b4e6feb332c..6976bc4d8ea 100644 --- a/pkg/schedule/schedulers/balance_leader.go +++ b/pkg/schedule/schedulers/balance_leader.go @@ -354,6 +354,7 @@ func (l *balanceLeaderScheduler) Schedule(cluster sche.SchedulerCluster, dryRun if dryRun { collector = plan.NewCollector(basePlan) } + defer l.filterCounter.Flush() batch := l.conf.getBatch() balanceLeaderScheduleCounter.Inc() @@ -395,7 +396,6 @@ func (l *balanceLeaderScheduler) Schedule(cluster sche.SchedulerCluster, dryRun } } } - l.filterCounter.Flush() l.retryQuota.GC(append(sourceCandidate.stores, targetCandidate.stores...)) return result, collector.GetPlans() } diff --git a/pkg/schedule/schedulers/balance_region.go b/pkg/schedule/schedulers/balance_region.go index 98e3be6e08a..e4202c133ad 100644 --- a/pkg/schedule/schedulers/balance_region.go +++ b/pkg/schedule/schedulers/balance_region.go @@ -114,6 +114,7 @@ func (s *balanceRegionScheduler) IsScheduleAllowed(cluster sche.SchedulerCluster func (s *balanceRegionScheduler) Schedule(cluster sche.SchedulerCluster, dryRun bool) ([]*operator.Operator, []plan.Plan) { basePlan := plan.NewBalanceSchedulerPlan() + defer s.filterCounter.Flush() var collector *plan.Collector if dryRun { collector = plan.NewCollector(basePlan) @@ -217,7 +218,6 @@ func (s *balanceRegionScheduler) Schedule(cluster sche.SchedulerCluster, dryRun } s.retryQuota.Attenuate(solver.Source) } - s.filterCounter.Flush() s.retryQuota.GC(stores) return nil, collector.GetPlans() }