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

*: better handle sysvar upgrades from older versions #31583

Merged
merged 11 commits into from
Mar 10, 2022

Conversation

morgo
Copy link
Contributor

@morgo morgo commented Jan 11, 2022

What problem does this PR solve?

Issue Number: close #31538

Problem Summary:

In v5.4 the GetGlobalSysVar() function returns an error if loading the value of a sysvar fails validation (in prior versions; no validation was performed at all, so this can be seen as a regression of #30293 ).

While this could be fixed by adjusting SHOW VARIABLES to handle these errors, it seems easier if we consistently handle upgrade issues in the GetGlobalSysVar() function in a determinstic way: replacing the default value if validation fails.

This also adds tests around system variable upgrades, which unfortunately were lacking previously.

This effectively reverts #31566 because it handles the issue in a different part of the code.

What is changed and how it works?

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
    Minor incompatibility: In 5.4 (and only 5.4) it was possible that some noop sysvars permitted incorrect values to be set. These now return an error again as in 5.3 and below.

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 11, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bb7133
  • djshow832

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.

@morgo morgo requested a review from a team as a code owner January 11, 2022 16:50
@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 Jan 11, 2022
@morgo
Copy link
Contributor Author

morgo commented Jan 11, 2022

/run-unit-test

Copy link
Contributor

@xhebox xhebox left a comment

Choose a reason for hiding this comment

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

I thought about this, but it does change the value of old settings. Maybe warnings are needed.

The behavior itself also deserve a release note and possibly documentation changes.

@xhebox
Copy link
Contributor

xhebox commented Jan 11, 2022

/cc @bb7133

@morgo
Copy link
Contributor Author

morgo commented Jan 11, 2022

I thought about this, but it does change the value of old settings. Maybe warnings are needed.

The old settings are considered invalid, and the validation function does not know how to make them valid. In theory we could ask the caller to handle the error (current behavior), but the problem is even though it has context it probably won't do a better job.

Edit: Ideally as we retire invalid settings, we should create bootstrap tasks to covert the old values. This will handle the cases in a "contextually aware" way. But this serves as a fallback when there is no bootstrap task.

@bb7133
Copy link
Member

bb7133 commented Jan 12, 2022

@xhebox @morgo Can we get a list of old default invalid settings from the old cluster? If they're invalid and meaningless for the old clusters, it's fine to fix them by changing them to the default value.

@morgo
Copy link
Contributor Author

morgo commented Jan 12, 2022

@xhebox @morgo Can we get a list of old default invalid settings from the old cluster? If they're invalid and meaningless for the old clusters, it's fine to fix them by changing them to the default value.

Yes, it's 100% possible to script and automate by iterating through git tags and exporting the values. We can then validate the values against master's validation function. @easonn7 can you confirm what the spread of supported upgrades is?

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 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 Jan 17, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jan 17, 2022

@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. label Mar 3, 2022
@morgo morgo removed the needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. label Mar 7, 2022
Comment on lines +3739 to +3740
require.Error(t, err)
require.Error(t, err, variable.ErrWrongTypeForVar.GenWithStackByArgs("max_user_connections").Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

So it's still a compatibility breaker? I'll add a label.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. We can add the label, but it is not very likely since this was only introduced in #31566 (5.4) - This PR reverts the previous PR with one that handles noops and other sysvars.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 8, 2022
@djshow832 djshow832 added the compatibility-breaker Violation of forwards/backwards compatibility in a design-time piece. label Mar 8, 2022
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. label Mar 8, 2022
session/session_test.go Outdated Show resolved Hide resolved
@morgo morgo removed the needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. label Mar 9, 2022
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. label Mar 9, 2022
Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 10, 2022
@bb7133
Copy link
Member

bb7133 commented Mar 10, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: bcc5383

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 10, 2022
@ti-chi-bot ti-chi-bot merged commit 22f4c33 into pingcap:master Mar 10, 2022
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Mar 10, 2022
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.4 in PR #32997

@morgo morgo deleted the fix-sv-upgrade branch March 10, 2022 16:46
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-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. 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. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
7 participants