From 79b4e63678f12b43c8ce01d757e7851b436745a3 Mon Sep 17 00:00:00 2001 From: Xiaoju Wu Date: Thu, 15 Dec 2022 15:38:52 +0800 Subject: [PATCH] *: fix auto analyze worker crash when killed by global memory limit (#39946) close pingcap/tidb#39947 --- statistics/handle/update.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/statistics/handle/update.go b/statistics/handle/update.go index d4ffeab2f389d..1acb82f7ba142 100644 --- a/statistics/handle/update.go +++ b/statistics/handle/update.go @@ -1065,6 +1065,11 @@ func (h *Handle) getAnalyzeSnapshot() (bool, error) { // HandleAutoAnalyze analyzes the newly created table or index. func (h *Handle) HandleAutoAnalyze(is infoschema.InfoSchema) (analyzed bool) { + defer func() { + if r := recover(); r != nil { + logutil.BgLogger().Error("HandleAutoAnalyze panicked", zap.Any("error", r), zap.Stack("stack")) + } + }() err := h.UpdateSessionVar() if err != nil { logutil.BgLogger().Error("[stats] update analyze version for auto analyze session failed", zap.Error(err))