Skip to content

Commit

Permalink
executor: fix setting system variables to original values failed afte…
Browse files Browse the repository at this point in the history
…r auto analyze (#37551)

close #37410
  • Loading branch information
xuyifangreeneyes committed Sep 14, 2022
1 parent f0d8d47 commit 0f4c3e6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions executor/adapter.go
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"fmt"
"runtime/trace"
"strconv"
"strings"
"sync/atomic"
"time"
Expand Down Expand Up @@ -451,10 +452,16 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) {
sctx := a.Ctx
ctx = util.SetSessionID(ctx, sctx.GetSessionVars().ConnectionID)
if _, ok := a.Plan.(*plannercore.Analyze); ok && sctx.GetSessionVars().InRestrictedSQL {
oriStats, _ := sctx.GetSessionVars().GetSystemVar(variable.TiDBBuildStatsConcurrency)
oriStats, ok := sctx.GetSessionVars().GetSystemVar(variable.TiDBBuildStatsConcurrency)
if !ok {
oriStats = strconv.Itoa(variable.DefBuildStatsConcurrency)
}
oriScan := sctx.GetSessionVars().DistSQLScanConcurrency()
oriIndex := sctx.GetSessionVars().IndexSerialScanConcurrency()
oriIso, _ := sctx.GetSessionVars().GetSystemVar(variable.TxnIsolation)
oriIso, ok := sctx.GetSessionVars().GetSystemVar(variable.TxnIsolation)
if !ok {
oriIso = "REPEATABLE-READ"
}
terror.Log(sctx.GetSessionVars().SetSystemVar(variable.TiDBBuildStatsConcurrency, "1"))
sctx.GetSessionVars().SetDistSQLScanConcurrency(1)
sctx.GetSessionVars().SetIndexSerialScanConcurrency(1)
Expand Down

0 comments on commit 0f4c3e6

Please sign in to comment.