From 36ec5803eb27956440876058c292a46f407dc445 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Wed, 21 Dec 2022 03:48:54 +0800 Subject: [PATCH] *: fix auto analyze worker crash when killed by tidb_mem_quota_analyze (#39946) (#39968) 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 1da73f188e3a1..8d50de9eada83 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))