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: inject random panic to AggExec #23139

Merged
merged 15 commits into from
Mar 9, 2021
Merged

Conversation

wshwsh12
Copy link
Contributor

@wshwsh12 wshwsh12 commented Mar 5, 2021

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:
In the project Tracking_Aggregate_Memory, there are many tracker.Consume, that will trigger panic when memory usage is too large. We should keep TiDB can cancel the sql successfully, and doesn't leak some resource.

What is changed and how it works?

Proposal: xxx

What's Changed:

How it Works:

Related changes

Check List

Tests

  • Unit test

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM
  • Breaking backward compatibility

Release note

  • No release note

@wshwsh12 wshwsh12 requested a review from a team as a code owner March 5, 2021 09:39
@wshwsh12 wshwsh12 requested review from XuHuaiyu and removed request for a team March 5, 2021 09:39
@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 5, 2021
@github-actions github-actions bot added the sig/execution SIG execution label Mar 5, 2021
@@ -293,7 +294,7 @@ func (e *HashAggExec) initForParallelExec(ctx sessionctx.Context) {
finalConcurrency := sessionVars.HashAggFinalConcurrency()
partialConcurrency := sessionVars.HashAggPartialConcurrency()
e.isChildReturnEmpty = true
e.finalOutputCh = make(chan *AfFinalResult, finalConcurrency)
e.finalOutputCh = make(chan *AfFinalResult, finalConcurrency+partialConcurrency+1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not only finalWorker will send data/error to the channel, but also fetchChildWorker/partialWorker will send errors to the channel.
If the buffer is not enough, the send will be blocked, and maybe lead dead lock.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the +1 for ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fetchChildData() also use the channel.

waitGroup.Wait()
waitGroup2.Wait()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When there causes any error, HashAggExec will close finishCh, and all goroutine will try to exit. We can't guarantee fetchChildWorker and partialWorker will exit before finalWorker.
If all finalWorkers exit first and close finalOutputCh, recoveryHashAgg() in fetchChildWorker/partialWorker will try to send message to a closed chan if there are some panic..

In my random panic test, I find the data race.

}

fpName := "github.com/pingcap/tidb/executor/ConsumeRandomPanic"
c.Assert(failpoint.Enable(fpName, `1%panic("ERROR 1105 (HY000): Out Of Memory Quota![conn_id=1]")`), IsNil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a random panic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use 1% to control the panic frequency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I change the panic possible to 5%, to reduce the retry times.

@wshwsh12 wshwsh12 requested review from XuHuaiyu and removed request for XuHuaiyu March 8, 2021 06:25
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 8, 2021
@wshwsh12 wshwsh12 requested a review from XuHuaiyu March 8, 2021 09:27
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 8, 2021
@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Mar 8, 2021

/run-all-tests

@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 8, 2021
@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Mar 8, 2021

/run-all-tests

executor/aggregate.go Outdated Show resolved Hide resolved
executor/aggregate.go Outdated Show resolved Hide resolved
@wshwsh12 wshwsh12 requested a review from XuHuaiyu March 9, 2021 06:44
executor/aggregate.go Outdated Show resolved Hide resolved
@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Mar 9, 2021

/lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 9, 2021
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • XuHuaiyu
  • ichn-hu

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 9, 2021
@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Mar 9, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: f81a1d5

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 9, 2021
@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Mar 9, 2021

/run-tics-test

@ti-chi-bot
Copy link
Member

@wshwsh12: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-community-infra/tichi repository.

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Mar 9, 2021

/run-unit-test

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Mar 9, 2021

/run-all-tests

@ti-chi-bot ti-chi-bot merged commit 83e70f7 into pingcap:master Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/test sig/execution SIG execution size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants