Skip to content

tidb-server should not persist ScopeNone sysvars during bootstrap #28667

@morgo

Description

@morgo

Enhancement

Discovered in #28555

It looks like during bootstrap the value of ScopeNone sysvars is persisted to mysql.global_variables, but this is never consulted when the sysvar is read:

// GetSessionOrGlobalSystemVar gets a system variable.
// If it is a session only variable, use the default value defined in code.
// Returns error if there is no such variable.
func GetSessionOrGlobalSystemVar(s *SessionVars, name string) (string, error) {
sv := GetSysVar(name)
if sv == nil {
return "", ErrUnknownSystemVar.GenWithStackByArgs(name)
}
if sv.HasNoneScope() {
return sv.Value, nil
}

If the intention is to persist, the var should be instead be changed to global Scope + set as read only instead.

Most of the ScopeNone sysvars are instance scoped (not global) and overwritten during server startup. So this is not causing any current bugs, it just looks confusing when inspecting the table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions