From 5d6c9f9b1c75973674c3639c0f67e114dba2dde4 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Thu, 5 Dec 2024 14:58:19 +0800 Subject: [PATCH] --wip-- [skip ci] --- pkg/schedule/coordinator.go | 6 +++++- pkg/schedule/core/prepare_checker.go | 3 --- server/cluster/cluster_test.go | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/schedule/coordinator.go b/pkg/schedule/coordinator.go index 1603bb01c34..bdb7fcb464d 100644 --- a/pkg/schedule/coordinator.go +++ b/pkg/schedule/coordinator.go @@ -217,7 +217,11 @@ func (c *Coordinator) runPrepareChecker() { case <-c.ctx.Done(): return case <-ticker.C: - c.prepareChecker.Check(c.cluster.GetBasicCluster()) + if !c.prepareChecker.IsPrepared() { + if c.prepareChecker.Check(c.cluster.GetBasicCluster()) { + log.Info("prepare checker is finished") + } + } } } } diff --git a/pkg/schedule/core/prepare_checker.go b/pkg/schedule/core/prepare_checker.go index 3c5432a9812..ffc2a507175 100644 --- a/pkg/schedule/core/prepare_checker.go +++ b/pkg/schedule/core/prepare_checker.go @@ -41,9 +41,6 @@ func NewPrepareChecker() *PrepareChecker { // Check checks if the coordinator has finished cluster information preparation. func (checker *PrepareChecker) Check(c *core.BasicCluster) bool { - if checker.IsPrepared() { - return true - } checker.Lock() defer checker.Unlock() diff --git a/server/cluster/cluster_test.go b/server/cluster/cluster_test.go index cbb4574ca7e..9b856ebc390 100644 --- a/server/cluster/cluster_test.go +++ b/server/cluster/cluster_test.go @@ -2873,6 +2873,7 @@ func TestCheckCache(t *testing.T) { cfg.ReplicaScheduleLimit = 0 }, nil, nil, re) defer cleanup() + co.GetPrepareChecker().SetPrepared() oc := co.GetOperatorController() checker := co.GetCheckerController() @@ -3028,6 +3029,7 @@ func TestPeerState(t *testing.T) { tc, co, cleanup := prepare(nil, nil, func(co *schedule.Coordinator) { co.Run() }, re) defer cleanup() + co.GetPrepareChecker().SetPrepared() // Transfer peer from store 4 to store 1. re.NoError(tc.addRegionStore(1, 10)) @@ -3072,6 +3074,7 @@ func TestAddScheduler(t *testing.T) { tc, co, cleanup := prepare(nil, nil, func(co *schedule.Coordinator) { co.Run() }, re) defer cleanup() + co.GetPrepareChecker().SetPrepared() controller := co.GetSchedulersController() re.Len(controller.GetSchedulerNames(), len(sc.DefaultSchedulers)) re.NoError(controller.RemoveScheduler(types.BalanceLeaderScheduler.String()))