-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
session, sessionctx: Make sysvar tidb_read_staleness TypeInt #32794
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/cc @morgo |
session/session_test.go
Outdated
@@ -5828,7 +5828,8 @@ func (s *testSessionSuite) TestTiDBReadStaleness(c *C) { | |||
c.Assert(err, NotNil) | |||
err = tk.ExecToErr("set @@tidb_read_staleness='foo'") | |||
c.Assert(err, NotNil) | |||
tk.MustExec("set @@tidb_read_staleness=''") | |||
err = tk.ExecToErr("set @@tidb_read_staleness='100'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case will fail in CI, I think it should be checked in sysvar.go
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this only supports negative values, we should test one of those too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morgo But why set @@tidb_read_staleness='100'
can succeed now? Because the MaxValue is 0, shouldn't the validation will automatically be performed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should. We don't have any other examples where the range is been -val
and 0
though, maybe there is a bug?
My point was that we should test that -100
is tested, as an example of an expected valid value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minValue
and maxValue
is checked in checkInt64SystemVar
, but it won't throw an error, only the warning is appended and the value will be set to minValue
or maxValue
if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yes! The MySQL behavior is to autoconvert to the closest permitted value + raise a warning. This is the case since #25686 It is only wrong typed values that will error.
If you modify the test to read back the value, it should be zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes. Do yo think we need to check it in the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any modification is needed for this PR? @morgo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it backward compatible? When a user sets the value in an older version, and then upgrades to this version, what will happen?
I think the affected statement is |
session/session_test.go
Outdated
@@ -5828,7 +5828,8 @@ func (s *testSessionSuite) TestTiDBReadStaleness(c *C) { | |||
c.Assert(err, NotNil) | |||
err = tk.ExecToErr("set @@tidb_read_staleness='foo'") | |||
c.Assert(err, NotNil) | |||
tk.MustExec("set @@tidb_read_staleness=''") | |||
err = tk.ExecToErr("set @@tidb_read_staleness='100'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this only supports negative values, we should test one of those too.
The variable is only session scoped, so we never persist the meta data. But I provided a comment on how to still accept empty if applications do this. You are right though, that this is still a concern for variables that include global scope. I have a PR @ #31583 - looking for your review :-) |
/run-unit-test |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/97be7b807080e8c02a660fe077e4bdb161755c15 |
@morgo Can anyone help me review and merge this PR? |
/cc @xhebox |
/hold |
/unhold |
This pull request has been accepted and is ready to merge. Commit hash: abaa9a2
|
I think it has been fixed. @xhebox |
What problem does this PR solve?
Issue Number: close #32763
Problem Summary:
What is changed and how it works?
Make sysvar tidb_read_staleness TypeInt
Check List
Tests
Side effects
Documentation
Release note