fix: Fix closing closed chan in proxy watcher (#30143)

issue: https://github.com/milvus-io/milvus/issues/30142

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
pull/30149/head
yihao.dai 2024-01-19 23:02:54 +08:00 committed by GitHub
parent d8025177fa
commit ddd741a5d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -54,7 +54,8 @@ type ProxyWatcher struct {
addSessionsFunc []func(*sessionutil.Session)
delSessionsFunc []func(*sessionutil.Session)
closeCh lifetime.SafeChan
closeOnce sync.Once
closeCh lifetime.SafeChan
}
// NewProxyWatcher helper function to create a proxyWatcher
@ -219,6 +220,8 @@ func (p *ProxyWatcher) getSessionsOnEtcd(ctx context.Context) ([]*sessionutil.Se
// Stop stops the ProxyManager
func (p *ProxyWatcher) Stop() {
p.closeCh.Close()
p.wg.Wait()
p.closeOnce.Do(func() {
p.closeCh.Close()
p.wg.Wait()
})
}