diff --git a/executor/analyze_test.go b/executor/analyze_test.go index a6cdea833df50..e6dfa2df4db5b 100644 --- a/executor/analyze_test.go +++ b/executor/analyze_test.go @@ -369,8 +369,8 @@ func TestAnalyzePartitionTableByConcurrencyInDynamic(t *testing.T) { for _, tc := range testcases { concurrency := tc.concurrency fmt.Println("testcase ", concurrency) - tk.MustExec(fmt.Sprintf("set @@tidb_merge_partition_stats_concurrency=%v", concurrency)) - tk.MustQuery("select @@tidb_merge_partition_stats_concurrency").Check(testkit.Rows(concurrency)) + tk.MustExec(fmt.Sprintf("set @@global.tidb_merge_partition_stats_concurrency=%v", concurrency)) + tk.MustQuery("select @@global.tidb_merge_partition_stats_concurrency").Check(testkit.Rows(concurrency)) tk.MustExec(fmt.Sprintf("set @@tidb_analyze_partition_concurrency=%v", concurrency)) tk.MustQuery("select @@tidb_analyze_partition_concurrency").Check(testkit.Rows(concurrency)) diff --git a/statistics/handle/handle.go b/statistics/handle/handle.go index 04779340d36ee..e0ee5f0e991d9 100644 --- a/statistics/handle/handle.go +++ b/statistics/handle/handle.go @@ -641,7 +641,16 @@ func (h *Handle) UpdateSessionVar() error { return err } h.mu.ctx.GetSessionVars().AnalyzeVersion = int(ver) - return err + verInString, err = h.mu.ctx.GetSessionVars().GlobalVarsAccessor.GetGlobalSysVar(variable.TiDBMergePartitionStatsConcurrency) + if err != nil { + return err + } + ver, err = strconv.ParseInt(verInString, 10, 64) + if err != nil { + return err + } + h.mu.ctx.GetSessionVars().AnalyzePartitionMergeConcurrency = int(ver) + return nil } // GlobalStats is used to store the statistics contained in the global-level stats