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))