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

MPP: Kill mpp queries #23056

Merged
merged 21 commits into from
Mar 12, 2021
Merged

MPP: Kill mpp queries #23056

merged 21 commits into from
Mar 12, 2021

Conversation

fzhedu
Copy link
Contributor

@fzhedu fzhedu commented Mar 2, 2021

What problem does this PR solve?

support killing mpp queries via mysql client like kill tidb query 3;

besides, avoid goroutine leaking once one of mpp goroutines errors.

Issue Number: close pingcap/tiflash#1443

Problem Summary:

What is changed and how it works?

mysql> show processlist;
+------+------+-----------------+------+---------+------+------------+---------------------------------------------------------------------------+
| Id   | User | Host            | db   | Command | Time | State      | Info                                                                      |
+------+------+-----------------+------+---------+------+------------+---------------------------------------------------------------------------+
|    3 | root | 127.0.0.1:49218 | test | Query   |    3 | autocommit | explain analyze select * from lineitem,orders where l_orderkey=o_orderkey |
|    5 | root | 127.0.0.1:49247 | test | Query   |    0 | autocommit | show processlist                                                          |
+------+------+-----------------+------+---------+------+------------+---------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> kill tidb query 3;
Query OK, 0 rows affected (0.00 sec)

the working client:

 explain analyze select * from lineitem,orders where l_orderkey=o_orderkey;
ERROR 1317 (70100): Query execution was interrupted

Proposal: xxx

What's Changed:

How it Works:

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:

Check List

Tests

  • Manual test (add detailed scripts or steps below)
  1. start another mysql client
  2. show processlist;
  3. kill tidb query xxx;

Release note

  • kill mpp queries

@fzhedu fzhedu requested a review from a team as a code owner March 2, 2021 13:30
@fzhedu fzhedu requested review from XuHuaiyu and removed request for a team March 2, 2021 13:30
@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 2, 2021
@github-actions github-actions bot added the sig/execution SIG execution label Mar 2, 2021
store/copr/mpp.go Outdated Show resolved Hide resolved
@fzhedu
Copy link
Contributor Author

fzhedu commented Mar 3, 2021

/run-check_dev

Copy link
Contributor

@ichn-hu ichn-hu left a comment

Choose a reason for hiding this comment

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

Is there any test for this?

@@ -227,6 +229,25 @@ func (m *mppIterator) handleDispatchReq(ctx context.Context, bo *tikv.Backoffer,
m.establishMPPConns(bo, req, taskMeta)
}

// TODO: retry once failed?
func (m *mppIterator) cancelMppTask(bo *tikv.Backoffer, meta *mpp.TaskMeta) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this function at least return a true or false on success or failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as comment in the NOTE.

m.sendToRespCh(&mppResponse{
err: errors.New(resp.Error.Msg),
})
// TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this TODO mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted.

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 6, 2021
Copy link
Member

@hanfei1991 hanfei1991 left a comment

Choose a reason for hiding this comment

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

Now that we have a mock mpp, why not write a unit test?

store/copr/mpp.go Outdated Show resolved Hide resolved
store/copr/mpp.go Outdated Show resolved Hide resolved
store/copr/mpp.go Outdated Show resolved Hide resolved
store/copr/mpp.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 8, 2021
@fzhedu
Copy link
Contributor Author

fzhedu commented Mar 9, 2021

Is there any test for this?

added.

store/copr/mpp.go Outdated Show resolved Hide resolved
store/copr/mpp.go Outdated Show resolved Hide resolved
store/copr/mpp.go Outdated Show resolved Hide resolved
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • hanfei1991
  • 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 12, 2021
@hanfei1991 hanfei1991 self-assigned this Mar 12, 2021
@fzhedu
Copy link
Contributor Author

fzhedu commented Mar 12, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: bba1eb9

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 12, 2021
@hanfei1991
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

@fzhedu: 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.

@fzhedu
Copy link
Contributor Author

fzhedu commented Mar 12, 2021

/run-unit-test

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

fzhedu commented Mar 12, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 5929ba4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/release-blocker This issue blocks a release. Please solve it ASAP. 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. type/new-feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need a mechanism to kill long-hang queries
6 participants