client: signal RG GC goroutines to exit properly
What problem does this PR solve?
Issue Number: Close #9745
What is changed and how does it work?
Adds a new cancel channel to signal GC goroutines when they can be stopped, to prevent goroutine leaks on client side.
Check List
Tests
- Unit test
- Integration test
- Manual test (add detailed scripts or steps below)
Manually tested using TiDB build with the same traffic which generates 600 extra goroutines stuck in
handleTokenBucketUpdateEvent. After the fix only 1 goroutine inhandleTokenBucketUpdateEvent. - No code
Code changes
- Has the configuration change
- Has HTTP API interfaces changed (Don't forget to add the declarative for the new API)
- Has persistent data change
Side effects
- Possible performance regression
- Increased code complexity
- Breaking backward compatibility
Related changes
- PR to update
pingcap/docs/pingcap/docs-cn: - PR to update
pingcap/tiup: - Need to cherry-pick to the release branch
Release note
None.
Hi @yzhan1. Thanks for your PR.
I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
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-sigs/prow repository.
@okJiang @JmPotato updated based on comments. PTAL, thanks!
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: okJiang Once this PR has been reviewed and has the lgtm label, please assign disksing for approval. For more information see the Code Review Process. Please ensure that each of them provides their approval before proceeding.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
[LGTM Timeline notifier]
Timeline:
2025-09-25 02:53:07.960048019 +0000 UTC m=+497998.030541694: :ballot_box_with_check: agreed by okJiang.
/retest
Codecov Report
:x: Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 76.90%. Comparing base (53b1fbf) to head (5754471).
:warning: Report is 26 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #9749 +/- ##
==========================================
+ Coverage 76.84% 76.90% +0.05%
==========================================
Files 484 486 +2
Lines 77142 77411 +269
==========================================
+ Hits 59281 59534 +253
- Misses 14258 14261 +3
- Partials 3603 3616 +13
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 76.90% <66.66%> (+0.05%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
/cc @JmPotato @bufferflies