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

executor: Fix coroutine leak after kill remote connection #46035

Merged
merged 2 commits into from
Aug 14, 2023
Merged
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
9 changes: 9 additions & 0 deletions executor/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -2608,6 +2608,7 @@
SetFromInfoSchema(sctx.GetInfoSchema()).
SetStoreType(kv.TiDB).
SetTiDBServerID(gcid.ServerID).
SetStartTS(math.MaxUint64). // To make check visibility success.

Check warning on line 2611 in executor/simple.go

View check run for this annotation

Codecov / codecov/patch

executor/simple.go#L2611

Added line #L2611 was not covered by tests
Build()
if err != nil {
return err
Expand All @@ -2618,6 +2619,14 @@
return err
}

// Must consume & close the response, otherwise coprocessor task will leak.
defer func() {
_ = resp.Close()
}()
if _, err := resp.Next(ctx); err != nil {
return errors.Trace(err)
}

Check warning on line 2628 in executor/simple.go

View check run for this annotation

Codecov / codecov/patch

executor/simple.go#L2623-L2628

Added lines #L2623 - L2628 were not covered by tests

logutil.BgLogger().Info("Killed remote connection", zap.Uint64("serverID", gcid.ServerID),
zap.Uint64("conn", gcid.ToConnID()), zap.Bool("query", query))
return err
Expand Down