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 hang in hash agg when exceeding memory limit leads to panic #57641

Merged
merged 5 commits into from
Nov 26, 2024

Conversation

xzhangxian1008
Copy link
Contributor

@xzhangxian1008 xzhangxian1008 commented Nov 22, 2024

What problem does this PR solve?

Issue Number: close #57546

Problem Summary:

Partial worker gets input by calling getChildInput function. In this function, we call Consume function to track memory occupied by input chunk. When sql's memory usage is high, there will be possible to lead to panic in Consume function. According to the synchronization rule, each time we get a chunk from getChildInput we need to call Done function for variable inflightChunkSync. However, when panic happens Done function is not called and the counter in inflightChunkSync will never be minused to 0 which leads to hang.

Solution: Each time waked up in channel in getChildInput function, we will set a variable named needDone. When panic happens in getChildInput function, we will catch the panic in this function and check if variable needDone is set to true then decide if we need to call Done function for inflightChunkSync, and rethrow the panic at last.

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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 issue that tidb may hang in hash agg when exceeding memory limit leads to panic

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 22, 2024
Copy link

tiprow bot commented Nov 22, 2024

Hi @xzhangxian1008. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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-sigs/prow repository.

@xzhangxian1008
Copy link
Contributor Author

/cc @wshwsh12 @XuHuaiyu

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.4559%. Comparing base (14ff938) to head (9256bbd).
Report is 13 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #57641        +/-   ##
================================================
+ Coverage   72.8292%   73.4559%   +0.6266%     
================================================
  Files          1676       1677         +1     
  Lines        463753     466002      +2249     
================================================
+ Hits         337748     342306      +4558     
+ Misses       105139     102946      -2193     
+ Partials      20866      20750       -116     
Flag Coverage Δ
integration 43.5382% <94.1176%> (?)
unit 72.3359% <100.0000%> (+0.1115%) ⬆️

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

Components Coverage Δ
dumpling 52.7673% <ø> (ø)
parser ∅ <ø> (∅)
br 45.5147% <ø> (+0.0769%) ⬆️

@xzhangxian1008
Copy link
Contributor Author

/cc @windtalker

@ti-chi-bot ti-chi-bot bot requested a review from windtalker November 25, 2024 02:39
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 25, 2024
@xzhangxian1008
Copy link
Contributor 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 Nov 25, 2024
@xzhangxian1008
Copy link
Contributor Author

/cc @windtalker @XuHuaiyu

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 25, 2024
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Nov 25, 2024
Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link

ti-chi-bot bot commented Nov 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: windtalker, 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:
  • OWNERS [XuHuaiyu,windtalker]

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 Nov 25, 2024
Copy link

ti-chi-bot bot commented Nov 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-25 07:54:19.994574828 +0000 UTC m=+450247.614229341: ☑️ agreed by XuHuaiyu.
  • 2024-11-25 12:08:05.246751544 +0000 UTC m=+465472.866406060: ☑️ agreed by windtalker.

Copy link

tiprow bot commented Nov 25, 2024

@xzhangxian1008: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow 9256bbd link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

@xzhangxian1008
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 26, 2024
@xzhangxian1008
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Nov 26, 2024

@xzhangxian1008: 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-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit e4f47d3 into pingcap:master Nov 26, 2024
23 of 24 checks passed
@ti-chi-bot
Copy link
Member

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

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-8.5 Should cherry pick this PR to release-8.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.

agg spill query kill and hang forever
4 participants