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

variables: return error when setting statement summary variables to invalid values #17108

Merged
merged 7 commits into from
May 12, 2020

Conversation

djshow832
Copy link
Contributor

@djshow832 djshow832 commented May 12, 2020

What problem does this PR solve?

Problem Summary:
System variables are transformed to a valid value according to min/max values. But this valid value is stored into TiKV, while the current server still uses the invalid value.
For example,

set global tidb_stmt_summary_refresh_interval = -1;

-1 is invalid and the value is transformed to 1 when validating it, and 1 is stored to mysql.global_variables table. However, 1 is not returned in the current SET statement, and the SET statement passes -1 to statement summary.

What is changed and how it works?

What's Changed:
Throw an error when it's set to an invalid value. This is simple and reasonable.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)
mysql> set global tidb_stmt_summary_refresh_interval=1<<31;
ERROR 1231 (42000): Variable 'tidb_stmt_summary_refresh_interval' can't be set to the value of '2147483648'
mysql> set session tidb_stmt_summary_refresh_interval=0;
ERROR 1231 (42000): Variable 'tidb_stmt_summary_refresh_interval' can't be set to the value of '0'

Side effects

  • Breaking backward compatibility

Release note

  • return error when setting statement summary system variables to invalid values.

@djshow832 djshow832 added type/bugfix This PR fixes a bug. compatibility-breaker Violation of forwards/backwards compatibility in a design-time piece. needs-cherry-pick-4.0 labels May 12, 2020
@djshow832
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

Rest LGTM

sessionctx/variable/varsutil.go Outdated Show resolved Hide resolved
Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Deardrops Deardrops left a comment

Choose a reason for hiding this comment

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

LGTM

@djshow832
Copy link
Contributor Author

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 12, 2020
@sre-bot
Copy link
Contributor

sre-bot commented May 12, 2020

/run-all-tests

@codecov
Copy link

codecov bot commented May 12, 2020

Codecov Report

Merging #17108 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #17108   +/-   ##
===========================================
  Coverage   80.2252%   80.2252%           
===========================================
  Files           510        510           
  Lines        140563     140563           
===========================================
  Hits         112767     112767           
  Misses        18819      18819           
  Partials       8977       8977           

@sre-bot
Copy link
Contributor

sre-bot commented May 12, 2020

cherry pick to release-4.0 in PR #17129

bb7133 pushed a commit that referenced this pull request May 12, 2020
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. status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants