From 1b172b674fa37259fabc4fcbc205274d4091fcce Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Wed, 14 Aug 2024 21:22:38 +0800 Subject: [PATCH] sessionctx: fix a deadlock when set `tidb_restricted_read_only = true` (#55407) close pingcap/tidb#53822, close pingcap/tidb#55373 --- pkg/sessionctx/variable/sysvar.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/sessionctx/variable/sysvar.go b/pkg/sessionctx/variable/sysvar.go index effb23bc25..622cfb9dac 100644 --- a/pkg/sessionctx/variable/sysvar.go +++ b/pkg/sessionctx/variable/sysvar.go @@ -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 }