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 IndexMerge worker panic because of closed channel #29803

Closed
wants to merge 17 commits into from

Conversation

guo-shaoge
Copy link
Collaborator

@guo-shaoge guo-shaoge commented Nov 15, 2021

Signed-off-by: guo-shaoge shaoge1994@163.com

What problem does this PR solve?

Issue Number: close #29610

Problem Summary:
When partial index worker got error, it will write give err to main worker using resultCh. But resultCh may already be closed(Maybe because process worker finished and close it).

image

What is changed and how it works?

  1. Add a log to indicate why we got error when fetching handles.
  2. partial index worker wirte its err msg using fetchCh instead of using resultCh directly.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below): this is covered by QA team.
  • No code

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

executor: fix IndexMerge worker panic because of closed channel

Signed-off-by: guo-shaoge <shaoge1994@163.com>
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

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 submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 15, 2021
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@guo-shaoge
Copy link
Collaborator Author

/run-common-test
/run-integration-copr-test
/run-integration-common-test

Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@ti-chi-bot ti-chi-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 23, 2021
@guo-shaoge
Copy link
Collaborator Author

/run-check_dev_2

@XuHuaiyu XuHuaiyu added type/bugfix This PR fixes a bug. sig/execution SIG execution labels Nov 30, 2021
@guo-shaoge
Copy link
Collaborator Author

/run-mysql-test

@guo-shaoge guo-shaoge changed the title executor: add log when index/table worker panic for IndexMergeReader executor: fix IndexMerge worker panic because of closed channel Jan 6, 2022
@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jan 6, 2022
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@guo-shaoge
Copy link
Collaborator Author

/cc @XuHuaiyu @wshwsh12

Signed-off-by: guo-shaoge <shaoge1994@163.com>
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 7, 2022
…ex_merge_panic

Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 7, 2022
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@sre-bot
Copy link
Contributor

sre-bot commented Jan 8, 2022

@guo-shaoge
Copy link
Collaborator Author

/run-integration-common-test tidb-test=pr/1509

1 similar comment
@guo-shaoge
Copy link
Collaborator Author

/run-integration-common-test tidb-test=pr/1509

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

We'd better to add more failpoint test cases

resultCh <- &lookupTableTask{
doneCh: doneCh,
func (w *partialIndexWorker) syncErr(ctx context.Context, fetchCh chan<- *lookupTableTask, err error) {
logutil.Logger(ctx).Error("got error when read index handles", zap.Error(err))
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 index handles?

sql := "select /*+ use_index_merge(t1) */ * from t1 where c1 < 10 or c2 < 10;"

c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/partialIndexWorkerError", "return"), IsNil)
err := tk.QueryToErr(sql)
Copy link
Contributor

Choose a reason for hiding this comment

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

check the error message here

@@ -684,7 +688,7 @@ func (e *IndexMergeReaderExecutor) handleHandlesFetcherPanic(ctx context.Context
logutil.Logger(ctx).Error(err4Panic.Error())
doneCh := make(chan error, 1)
doneCh <- err4Panic
resultCh <- &lookupTableTask{
ch <- &lookupTableTask{
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a failpoint test for this panic

@ti-chi-bot
Copy link
Member

@guo-shaoge: PR needs rebase.

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.

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 7, 2022
@guo-shaoge
Copy link
Collaborator Author

#41633
#41610
#41036

@guo-shaoge guo-shaoge closed this Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/execution SIG execution size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic: send on closed channel
5 participants