From 73c5653c763eb36757d7490b2ceb6703fe4652d3 Mon Sep 17 00:00:00 2001 From: Jiquan Long Date: Sat, 25 Dec 2021 17:52:17 +0800 Subject: [PATCH] Fix close querycoord panic (#14239) Signed-off-by: dragondriver --- internal/querycoord/query_coord.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/internal/querycoord/query_coord.go b/internal/querycoord/query_coord.go index 9e4eb78c07..36f3447691 100644 --- a/internal/querycoord/query_coord.go +++ b/internal/querycoord/query_coord.go @@ -241,11 +241,20 @@ func (qc *QueryCoord) Start() error { func (qc *QueryCoord) Stop() error { qc.UpdateStateCode(internalpb.StateCode_Abnormal) - qc.scheduler.Close() - log.Debug("close scheduler ...") - qc.indexChecker.close() - log.Debug("close index checker ...") - qc.loopCancel() + if qc.scheduler != nil { + qc.scheduler.Close() + log.Debug("close scheduler ...") + } + + if qc.indexChecker != nil { + qc.indexChecker.close() + log.Debug("close index checker ...") + } + + if qc.loopCancel != nil { + qc.loopCancel() + log.Info("cancel the loop of QueryCoord") + } qc.loopWg.Wait() qc.session.Revoke(time.Second)