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

store/tikv: fix CheckStreamTimeoutLoop goroutine leak #13812

Merged
merged 3 commits into from
Dec 5, 2019

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Nov 29, 2019

What problem does this PR solve?

When the TiKV server close, this goroutine leaks:

4 @ 0x4136c 0x51f74 0xc6af1c 0x70444
#	0xc6af1b	github.com/pingcap/tidb/store/tikv/tikvrpc.CheckStreamTimeoutLoop+0x16b	/Users/zhou/gorepo/src/github.com/pingcap/tidb/store/tikv/tikvrpc/tikvrpc.go:812

In our code, the CheckStreamTimeoutLoop goroutine is only closed when rpcClient close,
but the rpcClient never close before the TiDB process exit.

What is changed and how it works?

CheckStreamTimeoutLoop goroutine is initialized for each connArray, but they're not closed when connArray close, thus leading to the leak.

Move the done channel from rpcClient to connArray, the goroutine would exit when connArray is closed.

There is an idle recycle mechanism for the connArray to be closed when TiKV server is gone.

Check List

CheckStreamTimeoutLoop goroutine is initialized for each connArray,
but they're not closed when connArray close, thus leading to the leak
@tiancaiamao tiancaiamao added the type/bugfix This PR fixes a bug. label Nov 29, 2019
@tiancaiamao
Copy link
Contributor Author

tiancaiamao commented Nov 29, 2019

/cc @zhangjinpeng1987
PTAL @lysu @coocood

@codecov
Copy link

codecov bot commented Nov 29, 2019

Codecov Report

Merging #13812 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #13812   +/-   ##
===========================================
  Coverage   80.2734%   80.2734%           
===========================================
  Files           480        480           
  Lines        119889     119889           
===========================================
  Hits          96239      96239           
  Misses        16127      16127           
  Partials       7523       7523

@coocood
Copy link
Member

coocood commented Nov 29, 2019

LGTM

@ngaut ngaut requested a review from hicqu November 29, 2019 14:09
Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

LGTM

@lysu lysu added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. labels Dec 5, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 5, 2019

/run-all-tests

@SunRunAway
Copy link
Contributor

/run-cherry-picker

@sre-bot
Copy link
Contributor

sre-bot commented Dec 25, 2019

cherry pick to release-3.0 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tikv status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants