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

*: fix grpc client leak bug for AUTO_ID_CACHE=1 tables #48870

Merged
merged 6 commits into from
Nov 24, 2023

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Nov 24, 2023

What problem does this PR solve?

Issue Number: close #48869

Problem Summary:

What changed and how does it work?

Prior to this commit, each auto id allocator has it's own autoid client (a grpc connection inside), so if we have 60K tables there would be 60K tcp connections ...

After the fix, the autoid client is moved to domain so there should be only one autoid client instance. All the autoid allocator share this instance now.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

See the reproduce steps in the issue.
The test check tcp connection counts, it's harder to do that in unit test

  • No need to test
    • I checked and no code files have been changed.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

Fix grpc client leak bug for AUTO_ID_CACHE=1 tables, this bug is more likely to happen when there are lots of tables, and the error message is "connect: cannot assign requested address"

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 24, 2023
Copy link

tiprow bot commented Nov 24, 2023

Hi @tiancaiamao. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Nov 24, 2023
@tiancaiamao
Copy link
Contributor Author

A similiar leaky issue of etcd client on AUTO_ID_CACHE=1 tables, but this time it's the grpc client leak.
Ref #46324

Copy link

codecov bot commented Nov 24, 2023

Codecov Report

Merging #48870 (6943f31) into master (67b70e5) will decrease coverage by 17.4265%.
Report is 19 commits behind head on master.
The diff coverage is 71.4285%.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #48870         +/-   ##
=================================================
- Coverage   71.0203%   53.5939%   -17.4265%     
=================================================
  Files          1366       1587        +221     
  Lines        404643     597920     +193277     
=================================================
+ Hits         287379     320449      +33070     
- Misses        97264     254972     +157708     
- Partials      20000      22499       +2499     
Flag Coverage Δ
integration 35.1412% <71.0526%> (?)
unit 71.1038% <42.8571%> (+0.0835%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9663% <ø> (ø)
parser ∅ <ø> (∅)
br 55.4750% <50.0000%> (+2.4651%) ⬆️

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 24, 2023
Comment on lines +299 to +300
autoidCli := autoid.NewClientDiscover(etcdCli)
r := autoIDRequirement{store: kvStore, autoidCli: autoidCli}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it is more efficient to reuse etcdCli and autoidCli globally. We can improve this in another PR. /cc @D3Hunter

@tangenta
Copy link
Contributor

@tiancaiamao Is there any plan to refine the retry logic?

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 24, 2023
@tiancaiamao
Copy link
Contributor Author

tiancaiamao commented Nov 24, 2023

/test unit-test

1 similar comment
@tiancaiamao
Copy link
Contributor Author

/test unit-test

Copy link

ti-chi-bot bot commented Nov 24, 2023

@tiancaiamao: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test canary-notify-when-compatibility-sections-changed
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-br-integration-test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-ddl-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-mysql-client-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test

In response to this:

/test unit-test

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/test-infra repository.

Copy link

tiprow bot commented Nov 24, 2023

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

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/test-infra repository.

@tangenta
Copy link
Contributor

/retest

Copy link

tiprow bot commented Nov 24, 2023

@tangenta: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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/test-infra repository.

Copy link

ti-chi-bot bot commented Nov 24, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, tangenta

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 24, 2023
Copy link

ti-chi-bot bot commented Nov 24, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-11-24 06:42:03.791910568 +0000 UTC m=+559352.457136764: ☑️ agreed by tangenta.
  • 2023-11-24 09:08:10.501152106 +0000 UTC m=+568119.166378301: ☑️ agreed by lance6716.

@tiancaiamao
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Nov 24, 2023

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot merged commit 8eb1913 into pingcap:master Nov 24, 2023
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Nov 24, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #48891.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #48892.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Nov 24, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #48893.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Nov 24, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@tiancaiamao tiancaiamao deleted the autoid-grpc-leak branch November 24, 2023 11:32
tiancaiamao added a commit to ti-chi-bot/tidb that referenced this pull request Nov 24, 2023
tiancaiamao added a commit to tiancaiamao/tidb that referenced this pull request Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error message "connect: cannot assign requested address" on AUTO_ID_CACHE=1 tables
4 participants