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 CTE goroutine leak when exceeds mem quota #50828

Merged
merged 7 commits into from
Feb 19, 2024

Conversation

guo-shaoge
Copy link
Collaborator

@guo-shaoge guo-shaoge commented Jan 30, 2024

What problem does this PR solve?

Issue Number: close #50337

Problem Summary:

  1. when child.Close() return error, there may leaking resource.
  2. when seedExec.Open() return succ and recursiveExec.Open() returns error, and if this cte is shared by multiple operators, other operator may open seedExec again, which cause resource leaking.

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
drop table if exists t, t1, t2;
create table t (id int,name varchar(10));
insert into t values(1,'tt');
create table t1(id int,name varchar(10),name1 varchar(10),name2 varchar(10));
insert into t1 values(1,'tt','ttt','tttt'),(2,'dd','ddd','dddd');
create table t2(id int,name varchar(10),name1 varchar(10),name2 varchar(10),`date1` date);
insert into t2 values(1,'tt','ttt','tttt','2099-12-31'),(2,'dd','ddd','dddd','2099-12-31');
set tidb_mem_quota_query = 7000;
run cte sql for 2000 times (check https://github.com/pingcap/tidb/issues/50337 for detailed sql)

curl 'http://127.0.0.1:10080/debug/zip?seconds=5' --output debug4.zip and search copIteratorTaskSender to check if any goroutine leak.
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

fix CTE goroutine leak when child.Close() return error

Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/invalid-title do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 30, 2024
Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@guo-shaoge guo-shaoge changed the title fix CTE goroutine leak when child.Close() return error executor: fix CTE goroutine leak when child.Close() return error Jan 30, 2024
Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Merging #50828 (9c00311) into master (65d57c0) will increase coverage by 0.5167%.
Report is 8 commits behind head on master.
The diff coverage is 59.5744%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #50828        +/-   ##
================================================
+ Coverage   72.2960%   72.8127%   +0.5167%     
================================================
  Files          1467       1469         +2     
  Lines        361760     442752     +80992     
================================================
+ Hits         261538     322380     +60842     
- Misses        80904     100235     +19331     
- Partials      19318      20137       +819     
Flag Coverage Δ
integration 49.2217% <59.5744%> (?)
unit 70.3452% <59.5744%> (-1.8079%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 54.2644% <ø> (-2.0485%) ⬇️
parser ∅ <ø> (∅)
br 50.8153% <ø> (+4.4810%) ⬆️

@guo-shaoge
Copy link
Collaborator Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 31, 2024
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 31, 2024
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@guo-shaoge guo-shaoge removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 31, 2024
@guo-shaoge guo-shaoge changed the title executor: fix CTE goroutine leak when child.Close() return error executor: fix CTE goroutine leak when exceeds mem quota Jan 31, 2024
@guo-shaoge
Copy link
Collaborator Author

/retest

Copy link

ti-chi-bot bot commented Feb 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wshwsh12, XuHuaiyu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 18, 2024
Copy link

ti-chi-bot bot commented Feb 18, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-01-31 02:27:31.633440108 +0000 UTC m=+1532493.197737813: ☑️ agreed by XuHuaiyu.
  • 2024-02-18 03:09:27.507987407 +0000 UTC m=+153856.255610518: ☑️ agreed by wshwsh12.

@hawkingrei
Copy link
Member

/retest

@guo-shaoge
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Feb 19, 2024

@guo-shaoge: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Signed-off-by: guo-shaoge <shaoge1994@163.com>
@ti-chi-bot ti-chi-bot bot merged commit fa340f3 into pingcap:master Feb 19, 2024
21 checks passed
@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. labels Feb 20, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #51165.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 20, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #51166.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 20, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #51167.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 20, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 20, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.1: #51168.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-5.4: #51169.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 20, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
wshwsh12 added a commit to wshwsh12/tidb that referenced this pull request Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

goroutine leak when cte exceed mem_quota
5 participants