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

*: Make token limit into an instance variable #34324

Closed
wants to merge 1 commit into from
Closed

*: Make token limit into an instance variable #34324

wants to merge 1 commit into from

Conversation

subains
Copy link

@subains subains commented Apr 28, 2022

What problem does this PR solve?

Issue Number: ref #33769

Problem Summary:

The option token-limit has historically been a config option. But based on requirements from cloud & PM it should instead be a sysvar.

What is changed and how it works?

This does the minimum work to convert token-limit to a global (cluster-wide) sysvar, and removes the config option (placing it in the previously deprecated list).

Check List

Tests

  • Unit test
  • 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.

The TiDB configuration file option `token-limit` has been replaced by the system variable `tidb_token_limit`. This change makes it easier to modify this setting on a cluster wide basis.

@subains subains requested a review from a team as a code owner April 28, 2022 15:50
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

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 do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. labels Apr 28, 2022
@CLAassistant
Copy link

CLAassistant commented Apr 28, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Sunny Bains seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 28, 2022
@ti-chi-bot
Copy link
Member

Welcome @subains!

It looks like this is your first PR to pingcap/tidb 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tidb. 😃

@sre-bot
Copy link
Contributor

sre-bot commented Apr 28, 2022

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what is changed

Or if the count of mainly changed packages are more than 3, use

  • *: what is changed

After you have format title, you can leave a comment /run-check_title to recheck it

@morgo morgo self-requested a review April 28, 2022 15:53
)

// Process global variables.
var (
ProcessGeneralLog = atomic.NewBool(false)
GlobalLogMaxDays = atomic.NewInt32(int32(config.GetGlobalConfig().Log.File.MaxDays))
EnablePProfSQLCPU = atomic.NewBool(false)
TokenLimit = atomic.NewInt32(1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be overwritten, but just to save duplication better to use the const for 1000 here:

Suggested change
TokenLimit = atomic.NewInt32(1000)
TokenLimit = atomic.NewInt32(DefTiDBTokenLimit)

Comment on lines +687 to +689
ival, _ := strconv.Atoi(val)
TokenLimit.Store((int32)(ival))
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Some linters complain about uncaught errors. Because the validation is run based on "TypeInt" before this code is called, it will always be a valid number. So we can use our own helper function which doesn't return errors:

Suggested change
ival, _ := strconv.Atoi(val)
TokenLimit.Store((int32)(ival))
return nil
ival := tidbOptPositiveInt32(val, DefTiDBTokenLimit)
TokenLimit.Store(int32(ival))
return nil

Comment on lines -627 to 626
TokenLimit: 1000,
OOMUseTmpStorage: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a line in config.go for deprecated variables. If you add "token-limit" to it, it will mean a cleaner error for users.

@morgo morgo changed the title Make token limit into an instance variable *: Make token limit into an instance variable Apr 29, 2022
@morgo morgo added the compatibility-breaker Violation of forwards/backwards compatibility in a design-time piece. label Apr 29, 2022
@ti-chi-bot ti-chi-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 Apr 29, 2022
@ti-chi-bot
Copy link
Member

@subains: 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.

@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 5, 2022
@morgo
Copy link
Contributor

morgo commented May 10, 2022

As discussed on Slack - we need to discuss this one more, because it probably should be renamed and not global scope. So I am going to close this PR for now.

Thank you for your contribution! Sorry, we could not merge it this time.

@morgo morgo closed this May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility-breaker Violation of forwards/backwards compatibility in a design-time piece. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants