sessionctx: fix a deadlock when set tidb_restricted_read_only = true (#55407)

close pingcap/tidb#53822, close pingcap/tidb#55373
This commit is contained in:
Hangjie Mo
2024-08-14 21:22:38 +08:00
committed by GitHub
parent 6499137a0c
commit 1b172b674f

View File

@ -823,7 +823,11 @@ var defaultSysVars = []*SysVar{
on := TiDBOptOn(val)
// For user initiated SET GLOBAL, also change the value of TiDBSuperReadOnly
if on && s.StmtCtx.StmtType == "Set" {
err := s.GlobalVarsAccessor.SetGlobalSysVar(context.Background(), TiDBSuperReadOnly, "ON")
err := s.GlobalVarsAccessor.SetGlobalSysVarOnly(context.Background(), TiDBSuperReadOnly, "ON", false)
if err != nil {
return err
}
err = GetSysVar(TiDBSuperReadOnly).SetGlobal(context.Background(), s, "ON")
if err != nil {
return err
}