From 145de7f6b3730727ee52953b52594094daddfc2c Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 16 Dec 2024 14:22:36 +0800 Subject: [PATCH] statistics: get right max table id when to init stats Signed-off-by: Weizhen Wang --- pkg/statistics/handle/bootstrap.go | 7 ++++++- .../handle/handletest/initstats/load_stats_test.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/statistics/handle/bootstrap.go b/pkg/statistics/handle/bootstrap.go index efde5b994aac2..1006fbce5a85f 100644 --- a/pkg/statistics/handle/bootstrap.go +++ b/pkg/statistics/handle/bootstrap.go @@ -51,6 +51,11 @@ const ( var maxTidRecord MaxTidRecord +// GetMaxTidRecordForTest gets the max tid record for test. +func GetMaxTidRecordForTest() int64 { + return maxTidRecord.tid.Load() +} + // MaxTidRecord is to record the max tid. type MaxTidRecord struct { mu sync.Mutex @@ -84,7 +89,7 @@ func (*Handle) initStatsMeta4Chunk(cache statstypes.StatsCache, iter *chunk.Iter maxTidRecord.mu.Lock() defer maxTidRecord.mu.Unlock() if maxTidRecord.tid.Load() < maxPhysicalID { - maxTidRecord.tid.Store(physicalID) + maxTidRecord.tid.Store(maxPhysicalID) } } diff --git a/pkg/statistics/handle/handletest/initstats/load_stats_test.go b/pkg/statistics/handle/handletest/initstats/load_stats_test.go index 38a708c133d9c..37d0c45a9d030 100644 --- a/pkg/statistics/handle/handletest/initstats/load_stats_test.go +++ b/pkg/statistics/handle/handletest/initstats/load_stats_test.go @@ -100,4 +100,5 @@ func testConcurrentlyInitStats(t *testing.T) { require.False(t, col.IsAllEvicted()) } } + require.Equal(t, int64(126), handle.GetMaxTidRecordForTest()) }