-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
regression in tidb_restricted_read_only - can not disable after enabling #33003
Comments
@ichn-hu PTAL :-) |
I suppose this is the by-design behavior of tidb_restricted_read_only, as the transmissibility requirements in #31746 (review) states. |
we need to update the docs though |
The design has a usability problem if it allows the value to be changed, but not effective. If this is the intended case, then attempting to set it to |
I think this might be against the original design requirements, as it is for cloud replication scenario, where the cloud service DBA turns on the restricted read-only variable and implicitly turned on super read-only before the replication started, and when it is done, she would turn off the restricted read-only and it is upon to the user to turn off super read-only. cc @SunRunAway please take a look as this is your design. |
Another reference is that the behavior is similar like MySQL’s super_read_only and read_only. |
See the test-case above. I'm not touching the value of super_read_only: I'm just toggling |
When I change
|
Here is my suggestion: morgo@ubuntu:~/go/src/github.com/morgo/tidb$ git diff
diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go
index bdc9150f5..227172955 100644
--- a/sessionctx/variable/sysvar.go
+++ b/sessionctx/variable/sysvar.go
@@ -1063,13 +1063,29 @@ var defaultSysVars = []*SysVar{
{Scope: ScopeGlobal, Name: TiDBRestrictedReadOnly, Value: BoolToOnOff(DefTiDBRestrictedReadOnly), Type: TypeBool, SetGlobal: func(s *SessionVars, val string) error {
on := TiDBOptOn(val)
if on {
- err := s.GlobalVarsAccessor.SetGlobalSysVar(TiDBSuperReadOnly, "ON")
+ // Set SuperReadOnly to ON as well
+ err := s.GlobalVarsAccessor.SetGlobalSysVarOnly(TiDBSuperReadOnly, "ON")
if err != nil {
return err
}
}
RestrictedReadOnly.Store(on)
return nil
+ }, Validation: func(vars *SessionVars, normalizedValue string, _ string, _ ScopeFlag) (string, error) {
+ // Because setting ON also enables SuperReadOnly, we need to at least WARN
+ // that SETTING ON->OFF won't take effect when SuperReadOnly is ON.
+ // Another option is that we could also toggle SuperReadOnly OFF,
+ // but we don't currently do this.
+ if !TiDBOptOn(normalizedValue) {
+ result, err := vars.GlobalVarsAccessor.GetGlobalSysVar(TiDBSuperReadOnly)
+ if err != nil {
+ return normalizedValue, err
+ }
+ if TiDBOptOn(result) {
+ vars.StmtCtx.AppendWarning(errors.New("you need to set super_read_only OFF too, otherwise this doesn't make sense."))
+ }
+ }
+ return normalizedValue, nil
}},
{Scope: ScopeGlobal, Name: TiDBSuperReadOnly, Value: BoolToOnOff(DefTiDBSuperReadOnly), Type: TypeBool, Validation: func(vars *SessionVars, normalizedValue string, _ string, _ ScopeFlag) (string, error) {
on := TiDBOptOn(normalizedValue) |
It does make sense. When cloudAdmin sets |
Closing as not required. If users use |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
The create table statement should succeed.
This is a regression bisected to #31746
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: