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

execution: fix cte dead lock when used with IndexLookupJoin #27465

Merged
merged 4 commits into from
Aug 24, 2021

Conversation

guo-shaoge
Copy link
Collaborator

@guo-shaoge guo-shaoge commented Aug 21, 2021

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

What problem does this PR solve?

Issue Number: close #27410

Problem Summary:

  1. IndexLookupJoin Opens, and outer worker starts to use cte1.resTbl and cte2.resTbl
  2. execStmtResult.Close() is called directly without querying any result(e.g. IndexLookupJoin.Next() is never called)
  3. We reset cte1's resTbl and then reset cte2's resTbl, but the outer worker of IndexLookupJoin already hold cte2's resTbl and is waiting for cte1's resTbl.

Following is the log of execStmtResult.Close() and CTEExec.Next(), which prove above:

!!!!CTEExec.Next() &{{0 0} 1 [0xc004ae5ce0 0xc004ae5e00] 1024 0xc0059ba7e0 false 0 0xc004f27100}
!!!!! resetCTEStorageMap  &{{0 0} 1 [0xc004ae5860 0xc004ae58c0] 1024 0xc0059ba720 false 0 0xc004f26e00}
!!!!! resetCTEStorageMap  &{{1 0} 1 [0xc004ae5ce0 0xc004ae5e00] 1024 0xc0059ba7e0 false 0 0xc004f27100}
!!!!CTEExec.Next() &{{0 0} 1 [0xc004ae5860 0xc004ae58c0] 1024 0xc0059ba720 false 0 0xc004f26e00}

What is changed and how it works?

How it Works: Should wait for all workers to finish then we can reset cte.resTbl.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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

execution: fix cte dead lock when used with IndexLookupJoin

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

ti-chi-bot commented Aug 21, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bb7133
  • wjhuang2016

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 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 Aug 21, 2021
@github-actions github-actions bot added sig/execution SIG execution sig/sql-infra SIG: SQL Infra labels Aug 21, 2021
@guo-shaoge
Copy link
Collaborator Author

/cc @wjhuang2016

@guo-shaoge
Copy link
Collaborator Author

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

@guo-shaoge
Copy link
Collaborator Author

/run-check_dev_2

@unconsolable
Copy link
Contributor

The goroutine leak created by initializeAsyncParsing has been fixed by #27471

@guo-shaoge
Copy link
Collaborator Author

/label needs-cherry-pick-5.2

@guo-shaoge
Copy link
Collaborator Author

/label needs-cherry-pick-5.1

@zhouqiang-cl
Copy link
Contributor

/run-check_dev_2

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 24, 2021
@guo-shaoge
Copy link
Collaborator Author

/run-check_dev_2

@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 Aug 24, 2021
@bb7133
Copy link
Member

bb7133 commented Aug 24, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 6a26501

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 24, 2021
@ti-chi-bot ti-chi-bot merged commit 9691e50 into pingcap:master Aug 24, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 24, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.1 in PR #27536

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 24, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.2 in PR #27537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.1 needs-cherry-pick-release-5.2 release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/S Denotes a PR that changes 10-29 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.

bindinfo hang for 9 minutes
7 participants