Skip to content

Commit

Permalink
cherry pick pingcap#37078
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Oct 28, 2022
1 parent c56d702 commit 10e6c4e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,18 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) {
oriStats = strconv.Itoa(variable.DefBuildStatsConcurrency)
}
oriScan := sctx.GetSessionVars().DistSQLScanConcurrency()
autoConcurrency, err1 := sctx.GetSessionVars().GetSessionOrGlobalSystemVar(variable.TiDBAutoBuildStatsConcurrency)
terror.Log(err1)
if err1 == nil {
terror.Log(sctx.GetSessionVars().SetSystemVar(variable.TiDBBuildStatsConcurrency, autoConcurrency))
}
sVal, err2 := sctx.GetSessionVars().GetSessionOrGlobalSystemVar(variable.TiDBSysProcScanConcurrency)
terror.Log(err2)
if err2 == nil {
concurrency, err3 := strconv.ParseInt(sVal, 10, 64)
terror.Log(err3)
sctx.GetSessionVars().SetDistSQLScanConcurrency(int(concurrency))
}
oriIndex := sctx.GetSessionVars().IndexSerialScanConcurrency()
oriIso, ok := sctx.GetSessionVars().GetSystemVar(variable.TxnIsolation)
if !ok {
Expand Down
2 changes: 2 additions & 0 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,8 @@ var defaultSysVars = []*SysVar{
TableCacheLease.Store(val)
return nil
}},
{Scope: ScopeGlobal, Name: TiDBAutoBuildStatsConcurrency, Value: strconv.Itoa(DefTiDBAutoBuildStatsConcurrency), Type: TypeInt, MinValue: 1, MaxValue: MaxConfigurableConcurrency},
{Scope: ScopeGlobal, Name: TiDBSysProcScanConcurrency, Value: strconv.Itoa(DefTiDBSysProcScanConcurrency), Type: TypeInt, MinValue: 1, MaxValue: MaxConfigurableConcurrency},
// variable for top SQL feature.
// TopSQL enable only be controlled by TopSQL pub/sub sinker.
// This global variable only uses to update the global config which store in PD(ETCD).
Expand Down
7 changes: 7 additions & 0 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@ const (
// ranges would exceed the limit, it chooses less accurate ranges such as full range. 0 indicates that there is no memory
// limit for ranges.
TiDBOptRangeMaxSize = "tidb_opt_range_max_size"

// TiDBAutoBuildStatsConcurrency is used to set the build concurrency of auto-analyze.
TiDBAutoBuildStatsConcurrency = "tidb_auto_build_stats_concurrency"
// TiDBSysProcScanConcurrency is used to set the scan concurrency of for backend system processes, like auto-analyze.
TiDBSysProcScanConcurrency = "tidb_sysproc_scan_concurrency"
)

// TiDB vars that have only global scope
Expand Down Expand Up @@ -1072,6 +1077,8 @@ const (
DefTiDBForeignKeyChecks = false
DefTiDBOptRangeMaxSize = 0
DefTiDBCostModelVer = 1
DefTiDBAutoBuildStatsConcurrency = 1
DefTiDBSysProcScanConcurrency = 1
)

// Process global variables.
Expand Down

0 comments on commit 10e6c4e

Please sign in to comment.