From 518b3e8d553b32be8acaf8337c8a434b9ed1d398 Mon Sep 17 00:00:00 2001 From: Yiding Date: Thu, 5 Dec 2024 21:40:45 +0800 Subject: [PATCH 1/2] statistics: lite init used wrong value to build table stats ver --- pkg/statistics/handle/bootstrap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/statistics/handle/bootstrap.go b/pkg/statistics/handle/bootstrap.go index c354fb9d9d911..efde5b994aac2 100644 --- a/pkg/statistics/handle/bootstrap.go +++ b/pkg/statistics/handle/bootstrap.go @@ -134,7 +134,7 @@ func (*Handle) initStatsHistograms4ChunkLite(cache statstypes.StatsCache, iter * id := row.GetInt64(2) ndv := row.GetInt64(3) nullCount := row.GetInt64(5) - statsVer := row.GetInt64(7) + statsVer := row.GetInt64(8) // All the objects in the table share the same stats version. if statsVer != statistics.Version0 { table.StatsVer = int(statsVer) From 201a4477a6b29850d096175a89ee519a39bfdd58 Mon Sep 17 00:00:00 2001 From: Yiding Date: Thu, 5 Dec 2024 21:43:09 +0800 Subject: [PATCH 2/2] fix test --- pkg/statistics/handle/handletest/handle_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/statistics/handle/handletest/handle_test.go b/pkg/statistics/handle/handletest/handle_test.go index 5307cf95ca866..ad07df8879ab6 100644 --- a/pkg/statistics/handle/handletest/handle_test.go +++ b/pkg/statistics/handle/handletest/handle_test.go @@ -1414,6 +1414,7 @@ func TestInitStatsLite(t *testing.T) { require.NoError(t, h.InitStatsLite(context.Background())) statsTbl1 := h.GetTableStats(tblInfo) checkAllEvicted(t, statsTbl1) + require.Equal(t, int(statistics.Version2), statsTbl1.StatsVer) { // internal.AssertTableEqual(t, statsTbl0, statsTbl1) // statsTbl0 is loaded when the cache has pseudo table.