Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix subscription leak #37382

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions internal/rootcoord/dml_channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,7 @@
}

if params.PreCreatedTopicEnabled.GetAsBool() {
subName := fmt.Sprintf("pre-created-topic-check-%s", name)
ms.AsConsumer(ctx, []string{name}, subName, common.SubscriptionPositionUnknown)
// check if topic is existed
// kafka and rmq will err if the topic does not yet exist, pulsar will not
// allow topics is not empty, for the reason that when restart or upgrade, the topic is not empty
// if there are any message that not belong to milvus, will skip it
err := ms.CheckTopicValid(name)
if err != nil {
log.Error("created topic is invaild", zap.String("name", name), zap.Error(err))
panic("created topic is invaild")
}
d.checkPreCreatedTopic(ctx, factory, name)
}

ms.AsProducer([]string{name})
Expand All @@ -220,6 +210,29 @@
return d
}

func (d *dmlChannels) checkPreCreatedTopic(ctx context.Context, factory msgstream.Factory, name string) {
tmpMs, err := factory.NewMsgStream(ctx)
if err != nil {
panic(fmt.Sprintf("failed to add msgstream, name:%s, err:%v", name, err))

Check warning on line 216 in internal/rootcoord/dml_channels.go

View check run for this annotation

Codecov / codecov/patch

internal/rootcoord/dml_channels.go#L216

Added line #L216 was not covered by tests
}
defer tmpMs.Close()

subName := fmt.Sprintf("pre-created-topic-check-%s", name)
err = tmpMs.AsConsumer(ctx, []string{name}, subName, common.SubscriptionPositionUnknown)
if err != nil {
panic(fmt.Sprintf("failed to add consumer, name:%s, err:%v", name, err))

Check warning on line 223 in internal/rootcoord/dml_channels.go

View check run for this annotation

Codecov / codecov/patch

internal/rootcoord/dml_channels.go#L223

Added line #L223 was not covered by tests
}

// check if topic is existed
// kafka and rmq will err if the topic does not yet exist, pulsar will not
// allow topics is not empty, for the reason that when restart or upgrade, the topic is not empty
// if there are any message that not belong to milvus, will skip it
err = tmpMs.CheckTopicValid(name)
if err != nil {
panic(fmt.Sprintf("created topic is invalid, name:%s, err:%v", name, err))
}
}

func (d *dmlChannels) getChannelNames(count int) []string {
d.mut.Lock()
defer d.mut.Unlock()
Expand Down
Loading