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

sysvar, config: introduce tidb_connection_concurrency_limit as an instance scope sysvar. #34662

Closed
wants to merge 19 commits into from

Conversation

CbcWestwolf
Copy link
Member

What problem does this PR solve?

Issue Number: close #34583

Problem Summary:

For token-limit there is a use-case to make it online configurable. And the name of token-limit is too tied to an implementation, not what the feature does.

What is changed and how it works?

Introducing tidb_connection_concurrency_limit as a sysvar and a config item in [instance] section.

Check List

Tests

  • Unit test (added in previous UT)
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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.

None

@CbcWestwolf CbcWestwolf requested a review from a team as a code owner May 15, 2022 07:39
@ti-chi-bot
Copy link
Member

ti-chi-bot commented May 15, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • morgo

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 submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 15, 2022
@sre-bot
Copy link
Contributor

sre-bot commented May 15, 2022

concurrentLimiter: NewTokenLimiter(cfg.TokenLimit),
concurrentLimiter: NewTokenLimiter(uint(cfg.Instance.ConnectionConcurrencyLimit)),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will just be passed to server/ when the server starts?

If so, it will need to be refactored, since making changes to the sysvar won't apply until restart (which is a problem for instance vars, since the values are lost on restart too).

@morgo
Copy link
Contributor

morgo commented May 19, 2022

@CbcWestwolf Please fix linter issues:


[2022-05-18T15:07:18.743Z] linting

[2022-05-18T15:07:18.743Z]   ✘  https://revive.run/r#exported  exported method Server.UpdateTokenLimiter should have comment or be unexported  

[2022-05-18T15:07:18.743Z]   server/server.go:164:1

[2022-05-18T15:07:18.743Z] 

[2022-05-18T15:07:18.743Z]   ✘  https://revive.run/r#exported  exported method TokenLimiter.Resize should have comment or be unexported  

[2022-05-18T15:07:18.743Z]   server/tokenlimiter.go:46:1

[2022-05-18T15:07:18.743Z] 

[2022-05-18T15:07:18.743Z] ✘ 2 problems (2 errors, 0 warnings)

[2022-05-18T15:07:18.743Z] 

[2022-05-18T15:07:18.743Z] Errors:

[2022-05-18T15:07:18.743Z]   2  exported  

server/conn.go Outdated
@@ -1324,6 +1324,7 @@ func (cc *clientConn) dispatch(ctx context.Context, data []byte) error {
}

cc.server.releaseToken(token)
cc.server.UpdateTokenLimiter()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why update here and not in the SetGlobal func?

@CbcWestwolf
Copy link
Member Author

@CbcWestwolf Please fix linter issues:

Thanks, it is updated. PTAL.
And I'm adding some tests to check the UpdateTokenLimiter. I'm afraid that this PR introduce a great performance regression due to the mutex in TokenLimiter, do you think so?

@morgo
Copy link
Contributor

morgo commented May 19, 2022

Thanks, it is updated. PTAL.
And I'm adding some tests to check the UpdateTokenLimiter. I'm afraid that this PR introduce a great performance regression due to the mutex in TokenLimiter, do you think so?

I was actually wondering the same thing. I think we might need to test it.

The other option is to refactor to use an atomic for the limit, and not use a resizer. It probably does change quite a bit of code though, so I'm not sure if its better.

@ti-chi-bot ti-chi-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 May 19, 2022
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 19, 2022
@morgo morgo self-requested a review May 25, 2022 23:46
Copy link
Contributor

@morgo morgo left a comment

Choose a reason for hiding this comment

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

LGTM, please fix conflicts

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 25, 2022
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 8, 2022
@CbcWestwolf CbcWestwolf marked this pull request as draft June 23, 2022 08:37
@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 23, 2022
@ti-chi-bot ti-chi-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 Aug 4, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2022
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 12, 2022
@ti-chi-bot
Copy link
Member

@CbcWestwolf: PR needs rebase.

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.

@codecov
Copy link

codecov bot commented Jul 22, 2023

Codecov Report

Merging #34662 (2985c9a) into master (fbbae46) will increase coverage by 11.9434%.
Report is 4476 commits behind head on master.
The diff coverage is 67.6878%.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #34662         +/-   ##
=================================================
+ Coverage   61.8719%   73.8153%   +11.9434%     
=================================================
  Files           891        990         +99     
  Lines        284074     313741      +29667     
=================================================
+ Hits         175762     231589      +55827     
+ Misses        94536      67553      -26983     
- Partials      13776      14599        +823     

@ti-chi-bot ti-chi-bot bot deleted a comment from ti-chi-bot Dec 19, 2023
Copy link

tiprow bot commented Feb 27, 2024

@CbcWestwolf: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
tiprow_fast_test 2985c9a link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Copy link

ti-chi-bot bot commented Aug 28, 2024

@CbcWestwolf: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-mysql-client-test 2985c9a link true /test pull-mysql-client-test
pull-integration-ddl-test 2985c9a link true /test pull-integration-ddl-test
idc-jenkins-ci-tidb/check_dev 2985c9a link true /test check-dev
idc-jenkins-ci-tidb/mysql-test 2985c9a link true /test mysql-test
idc-jenkins-ci-tidb/build 2985c9a link true /test build
idc-jenkins-ci-tidb/check_dev_2 2985c9a link true /test check-dev2
idc-jenkins-ci-tidb/unit-test 2985c9a link true /test unit-test
pull-br-integration-test 2985c9a link true /test pull-br-integration-test
pull-lightning-integration-test 2985c9a link true /test pull-lightning-integration-test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make token-limit configurable as an INSTANCE scoped variable
5 participants