fix: [2.5] Make controller wait checker worker quit (#42704) (#42726)

Cherry-pick from master
pr: #42704
Related to #42702

This patch add wait logic for `CheckerController` 
Nil check already exists due to code branching

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2025-06-16 15:14:38 +08:00 committed by GitHub
parent 3b3f25d074
commit 3d58b2ecee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,6 +50,7 @@ type CheckerController struct {
scheduler task.Scheduler
checkers map[utils.CheckerType]Checker
wg sync.WaitGroup
stopOnce sync.Once
}
@ -96,7 +97,11 @@ func (controller *CheckerController) Start() {
controller.cancel = cancel
for checker := range controller.checkers {
go controller.startChecker(ctx, checker)
controller.wg.Add(1)
go func() {
defer controller.wg.Done()
controller.startChecker(ctx, checker)
}()
}
}
@ -145,6 +150,8 @@ func (controller *CheckerController) Stop() {
if controller.cancel != nil {
controller.cancel()
}
controller.wg.Wait()
})
}