From 5fbffeed9705c57ab2535c2d3405ea7bc3117ad9 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Mon, 19 Feb 2024 15:36:25 +0800 Subject: [PATCH] *: fix AnalyzePartitionMergeConcurrency unavailable (#47589) (#51141) close pingcap/tidb#47594 --- executor/analyze_test.go | 4 ++-- statistics/handle/handle.go | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/executor/analyze_test.go b/executor/analyze_test.go index ce5e9b4a9130a..48e725ec912b0 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 1a934e068a22a..b9bb52d4a3ac6 100644 --- a/statistics/handle/handle.go +++ b/statistics/handle/handle.go @@ -636,6 +636,15 @@ func (h *Handle) UpdateSessionVar() error { return err } h.mu.ctx.GetSessionVars().AnalyzeVersion = int(ver) + verInString, err = h.mu.ctx.GetSessionVars().GlobalVarsAccessor.GetGlobalSysVar(variable.TiDBMergePartitionStatsConcurrency) + if err != nil { + return err + } + ver2, err := strconv.ParseInt(verInString, 10, 64) + if err != nil { + return err + } + h.mu.ctx.GetSessionVars().AnalyzePartitionMergeConcurrency = int(ver2) return err }