enhance: Close component in topological order when unsub channel (#40796)

Related to #40795

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2025-03-21 10:22:11 +08:00 committed by GitHub
parent d7df78a6c9
commit 9824615efb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -357,10 +357,11 @@ func (node *QueryNode) UnsubDmChannel(ctx context.Context, req *querypb.UnsubDmC
defer node.unsubscribingChannels.Remove(req.GetChannelName())
delegator, ok := node.delegators.GetAndRemove(req.GetChannelName())
if ok {
node.pipelineManager.Remove(req.GetChannelName())
// close the delegator first to block all coming query/search requests
delegator.Close()
node.pipelineManager.Remove(req.GetChannelName())
node.manager.Segment.RemoveBy(ctx, segments.WithChannel(req.GetChannelName()), segments.WithType(segments.SegmentTypeGrowing))
node.manager.Collection.Unref(req.GetCollectionID(), 1)
}

View File

@ -67,7 +67,11 @@ func (p *streamPipeline) work() {
case <-p.closeCh:
log.Ctx(context.TODO()).Debug("stream pipeline input closed")
return
case msg := <-p.input:
case msg, ok := <-p.input:
if !ok {
log.Ctx(context.TODO()).Debug("stream pipeline input closed")
return
}
p.lastAccessTime.Store(time.Now())
log.Ctx(context.TODO()).RatedDebug(10, "stream pipeline fetch msg", zap.Int("sum", len(msg.Msgs)))
p.pipeline.inputChannel <- msg
@ -158,12 +162,15 @@ func (p *streamPipeline) Start() error {
func (p *streamPipeline) Close() {
p.closeOnce.Do(func() {
// close datasource first
p.dispatcher.Deregister(p.vChannel)
// close stream input
close(p.closeCh)
p.closeWg.Wait()
if p.scanner != nil {
p.scanner.Close()
}
p.dispatcher.Deregister(p.vChannel)
// close the underline pipeline
p.pipeline.Close()
})
}