Skip to content

Commit

Permalink
statistics: update some vars for internal sessions correctly (#53977) (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Nov 11, 2024
1 parent db9b8e1 commit 6336e2f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions executor/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,17 @@ func (e *AnalyzeExec) handleResultsError(
resultsCh <-chan *statistics.AnalyzeResults,
taskNum int,
) error {
partitionStatsConcurrency := e.ctx.GetSessionVars().AnalyzePartitionConcurrency
oriPartitionStatsConcurrency, err := e.ctx.GetSessionVars().GetSessionOrGlobalSystemVar(
ctx,
variable.TiDBAnalyzePartitionConcurrency,
)
if err != nil {
return err
}
partitionStatsConcurrency, err := strconv.Atoi(oriPartitionStatsConcurrency)
if err != nil {
return err
}
// the concurrency of handleResultsError cannot be more than partitionStatsConcurrency
partitionStatsConcurrency = mathutil.Min(taskNum, partitionStatsConcurrency)
// If partitionStatsConcurrency > 1, we will try to demand extra session from Domain to save Analyze results in concurrency.
Expand All @@ -307,7 +317,6 @@ func (e *AnalyzeExec) handleResultsError(
// save analyze results in single-thread.
statsHandle := domain.GetDomain(e.ctx).StatsHandle()
panicCnt := 0
var err error
for panicCnt < concurrency {
results, ok := <-resultsCh
if !ok {
Expand Down

0 comments on commit 6336e2f

Please sign in to comment.