From 427a958508b03041270618acc1e43861716304df Mon Sep 17 00:00:00 2001 From: JmPotato Date: Sun, 22 Sep 2024 19:02:48 +0800 Subject: [PATCH] executor: verify the existence of the resource group before switching (#56145) ref pingcap/tidb#54434 --- pkg/executor/adapter.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/executor/adapter.go b/pkg/executor/adapter.go index 0678f3217945a..cd1f3affea5c6 100644 --- a/pkg/executor/adapter.go +++ b/pkg/executor/adapter.go @@ -555,7 +555,12 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) { return nil, err } if len(switchGroupName) > 0 { - stmtCtx.ResourceGroupName = switchGroupName + group, err := rm.ResourceGroupCtl.GetResourceGroup(switchGroupName) + if err != nil || group == nil { + logutil.BgLogger().Debug("invalid switch resource group", zap.String("switch-group-name", switchGroupName), zap.Error(err)) + } else { + stmtCtx.ResourceGroupName = switchGroupName + } } } ctx = a.observeStmtBeginForTopSQL(ctx)