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

variable: add system variable 'tidb_resource_control_strict_mode' #54033

Merged
merged 5 commits into from
Jun 20, 2024

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Jun 14, 2024

What problem does this PR solve?

Issue Number: ref #53440

Problem Summary:
Add new global variable tidb_resource_control_strict_mode:

  • If set to 'ON', use need to have RESOURCE_GROUP_ADMIN or RESOURCE_GROUP_USER privilege to execute SET RESOURCE GROUP or use hint RESOURCE_GROUP() to change current resource group.
  • If set to 'OFF', the privilege is bypassed, all user can execute SET RESOURCE GROUP or use hint RESOURCE_GROUP() as before.

For new cluster, the default value is 'ON', but for cluster upgraded from old version, the default value is 'OFF'.

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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.

Add new global variable `tidb_resource_control_strict_mode` to config whether privilege check should be apply to operation that change current session/statement's resource group.

@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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/planner SIG: Planner labels Jun 14, 2024
Copy link

tiprow bot commented Jun 14, 2024

Hi @glorv. 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-sigs/prow repository.

@glorv
Copy link
Contributor Author

glorv commented Jun 14, 2024

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Jun 14, 2024
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 93.61702% with 3 lines in your changes missing coverage. Please review.

Project coverage is 56.4624%. Comparing base (29fc940) to head (7fbf10b).
Report is 34 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54033         +/-   ##
=================================================
- Coverage   72.4718%   56.4624%   -16.0094%     
=================================================
  Files          1508       1637        +129     
  Lines        432045     616436     +184391     
=================================================
+ Hits         313111     348055      +34944     
- Misses        99516     244400     +144884     
- Partials      19418      23981       +4563     
Flag Coverage Δ
integration 38.3059% <42.5531%> (?)
unit 71.4914% <93.6170%> (+0.0288%) ⬆️

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

Components Coverage Δ
dumpling 52.9656% <ø> (+0.0188%) ⬆️
parser ∅ <ø> (∅)
br 61.7346% <ø> (+19.4854%) ⬆️

@glorv
Copy link
Contributor Author

glorv commented Jun 17, 2024

@nolouch @tiancaiamao PTAL, thanks~

@@ -2779,6 +2779,15 @@ var defaultSysVars = []*SysVar{
}, GetGlobal: func(ctx context.Context, vars *SessionVars) (string, error) {
return BoolToOnOff(EnableResourceControl.Load()), nil
}},
{Scope: ScopeGlobal, Name: TiDBResourceControlStrictMode, Value: BoolToOnOff(DefTiDBResourceControlStrictMode), Type: TypeBool, SetGlobal: func(ctx context.Context, vars *SessionVars, s string) error {
if TiDBOptOn(s) != EnableResourceControl.Load() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if TiDBOptOn(s) != EnableResourceControl.Load() {
if TiDBOptOn(s) != EnableResourceControlStrictMode.Load() {

should be EnableResourceControlStrictMode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. It's weird that unit test does not find this bug.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 17, 2024
@glorv glorv requested a review from qw4990 June 18, 2024 08:15
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 20, 2024
Copy link

ti-chi-bot bot commented Jun 20, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-17 07:05:45.656278112 +0000 UTC m=+12072.141766944: ☑️ agreed by nolouch.
  • 2024-06-20 02:54:32.985029667 +0000 UTC m=+256199.470518484: ☑️ agreed by qw4990.

@glorv glorv requested a review from 3pointer June 20, 2024 03:07
@easonn7
Copy link

easonn7 commented Jun 20, 2024

/approve

Copy link

ti-chi-bot bot commented Jun 20, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3pointer, easonn7, nolouch, qw4990

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 the approved label Jun 20, 2024
@ti-chi-bot ti-chi-bot bot merged commit 6fe4f9e into pingcap:master Jun 20, 2024
35 of 36 checks passed
@glorv glorv deleted the rg-strict-mode branch June 20, 2024 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner 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.

5 participants