From aee5df828ac8945ef4a70e54f5c769404b5db42c Mon Sep 17 00:00:00 2001 From: elsa0520 Date: Wed, 20 Dec 2023 19:16:55 +0800 Subject: [PATCH 1/2] statistics: add some key info in sync load timeout log --- pkg/statistics/column.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/statistics/column.go b/pkg/statistics/column.go index 5f2d38efdf011..f3fc75fd6469a 100644 --- a/pkg/statistics/column.go +++ b/pkg/statistics/column.go @@ -168,7 +168,9 @@ func (c *Column) IsInvalid( if (!c.IsStatsInitialized() || c.IsLoadNeeded()) && stmtctx != nil { if stmtctx.StatsLoad.Timeout > 0 { logutil.BgLogger().Warn("Hist for column should already be loaded as sync but not found.", - zap.String(strconv.FormatInt(c.Info.ID, 10), c.Info.Name.O)) + zap.String("table_id", strconv.FormatInt(c.PhysicalID, 10)), + zap.String("column_id", strconv.FormatInt(c.Info.ID, 10)), + zap.String("column_name", c.Info.Name.O)) } // In some tests, the c.Info is not set, so we add this check here. // When we are using stats from PseudoTable(), the table ID will possibly be -1. From 522b123ea67c04e1cf81873246da5d4338a09f1a Mon Sep 17 00:00:00 2001 From: elsa0520 Date: Wed, 20 Dec 2023 19:35:00 +0800 Subject: [PATCH 2/2] fix --- pkg/statistics/column.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/statistics/column.go b/pkg/statistics/column.go index f3fc75fd6469a..507a72c2e04a3 100644 --- a/pkg/statistics/column.go +++ b/pkg/statistics/column.go @@ -15,8 +15,6 @@ package statistics import ( - "strconv" - "github.com/pingcap/tidb/pkg/parser/model" "github.com/pingcap/tidb/pkg/parser/mysql" "github.com/pingcap/tidb/pkg/planner/util/debugtrace" @@ -168,8 +166,8 @@ func (c *Column) IsInvalid( if (!c.IsStatsInitialized() || c.IsLoadNeeded()) && stmtctx != nil { if stmtctx.StatsLoad.Timeout > 0 { logutil.BgLogger().Warn("Hist for column should already be loaded as sync but not found.", - zap.String("table_id", strconv.FormatInt(c.PhysicalID, 10)), - zap.String("column_id", strconv.FormatInt(c.Info.ID, 10)), + zap.Int64("table_id", c.PhysicalID), + zap.Int64("column_id", c.Info.ID), zap.String("column_name", c.Info.Name.O)) } // In some tests, the c.Info is not set, so we add this check here.