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: kill tableReader for each connection correctly (#18277) #18506

Merged
merged 5 commits into from
Jul 20, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #18277 to release-3.0


What problem does this PR solve?

Issue Number: close a part of #18057

Problem Summary:
The tableReader in the coprocessor may retry many times to read regions, druing which, it cannot be aware of the cancelation from client. It may take much of memory for a long time.

What is changed and how it works?

Proposal: detect Killed to stop the goroutine.

What's Changed: should not use CompareAndSwap to change the Killed before Close(), because many runninig goroutines should detect the Killed.

How it Works: the TableReader the detect the killed in every loop.
The query may not exit quickly, because the query do some close work.

Check List

Tests

  • Integration test
  • Manual test (add detailed scripts or steps below)
    test on mocktikv:
step1. explain analyze select * from lineitem;
step2. kill tidb sessionID on another client;
to see the connection is cancelled.

similarly test on TiFlash is ok.

Release note

  • To speed up canceling a query

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@fzhedu please accept the invitation then you can push to the cherry-pick pull requests.
https://github.com/ti-srebot/tidb/invitations

@fzhedu
Copy link
Contributor

fzhedu commented Jul 13, 2020

/rebuild

server/server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 15, 2020
@SunRunAway SunRunAway requested a review from qw4990 July 15, 2020 05:17
Copy link
Contributor

@qw4990 qw4990 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 20, 2020
@qw4990
Copy link
Contributor

qw4990 commented Jul 20, 2020

/merge

@ti-srebot
Copy link
Contributor Author

Sorry @qw4990, you don't have permission to trigger auto merge event on this branch.

@qw4990
Copy link
Contributor

qw4990 commented Jul 20, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 20, 2020
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot merged commit 75a6168 into pingcap:release-3.0 Jul 20, 2020
@SunRunAway SunRunAway deleted the release-3.0-2b0b34b88e43 branch July 20, 2020 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/3.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants