From 6cc809c06da4d9c079113e7eb61ccf18df6a5bb7 Mon Sep 17 00:00:00 2001 From: Yiding Date: Wed, 4 Dec 2024 02:40:31 +0800 Subject: [PATCH] add one more log --- pkg/statistics/handle/cache/statscache.go | 6 ++++++ pkg/statistics/handle/storage/read.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/pkg/statistics/handle/cache/statscache.go b/pkg/statistics/handle/cache/statscache.go index d2e034e09149c..ddfb8c8763bb2 100644 --- a/pkg/statistics/handle/cache/statscache.go +++ b/pkg/statistics/handle/cache/statscache.go @@ -105,6 +105,7 @@ func (s *StatsCacheImpl) Update(ctx context.Context, is infoschema.InfoSchema, t noStatsInMemoryIDs := make([]int64, 0, len(rows)) noTableMetaIDs := make([]int64, 0, 100) noStorageIDs := make([]int64, 0, 100) + noStatsMetaIDs := make([]int64, 0, 100) for _, row := range rows { version := row.GetUint64(0) @@ -148,6 +149,10 @@ func (s *StatsCacheImpl) Update(ctx context.Context, is infoschema.InfoSchema, t noStatsInMemoryIDs = append(noStatsInMemoryIDs, physicalID) err = nil } + if err != nil && err.Error() == "no stats meta" { + noStatsMetaIDs = append(noStatsMetaIDs, physicalID) + err = nil + } // Error is not nil may mean that there are some ddl changes on this table, we will not update it. if err != nil { statslogutil.StatsLogger().Error( @@ -202,6 +207,7 @@ func (s *StatsCacheImpl) Update(ctx context.Context, is infoschema.InfoSchema, t zap.Int64s("IDs with no table meta", noTableMetaIDs), zap.Int64s("IDs with no stats", noStorageIDs), zap.Int64s("no stats in memory IDs", noStatsInMemoryIDs), + zap.Int64s("no stats meta IDs", noStatsMetaIDs), ) } return nil diff --git a/pkg/statistics/handle/storage/read.go b/pkg/statistics/handle/storage/read.go index 385deb3c11ab8..4379ff0885417 100644 --- a/pkg/statistics/handle/storage/read.go +++ b/pkg/statistics/handle/storage/read.go @@ -532,6 +532,12 @@ func TableStatsFromStorage(sctx sessionctx.Context, snapshot uint64, tableInfo * table.Pseudo = false realtimeCount, modidyCount, isNull, err := StatsMetaCountAndModifyCount(util.StatsCtx, sctx, tableID) + if err != nil { + return nil, err + } + if isNull { + return nil, errors.Errorf("no stats meta") + } if err != nil || isNull { return nil, err }