Skip to content

Commit

Permalink
statistics: do not block when sending analyze result (#52107)
Browse files Browse the repository at this point in the history
close #51993
  • Loading branch information
Rustin170506 authored Mar 27, 2024
1 parent a72b319 commit dde0a54
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/executor/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,15 @@ func (e *AnalyzeExec) analyzeWorker(taskCh <-chan *analyzeTask, resultsCh chan<-
if r := recover(); r != nil {
logutil.BgLogger().Error("analyze worker panicked", zap.Any("recover", r), zap.Stack("stack"))
metrics.PanicCounter.WithLabelValues(metrics.LabelAnalyze).Inc()
resultsCh <- &statistics.AnalyzeResults{
Err: getAnalyzePanicErr(r),
// If errExitCh is closed, it means the whole analyze task is aborted. So we do not need to send the result to resultsCh.
err := getAnalyzePanicErr(r)
select {
case resultsCh <- &statistics.AnalyzeResults{
Err: err,
Job: task.job,
}:
case <-e.errExitCh:
logutil.BgLogger().Error("analyze worker exits because the whole analyze task is aborted", zap.Error(err))
}
}
}()
Expand Down

0 comments on commit dde0a54

Please sign in to comment.