diff --git a/pkg/statistics/handle/bootstrap.go b/pkg/statistics/handle/bootstrap.go index 276355250c53c..3d67e3ed58c61 100644 --- a/pkg/statistics/handle/bootstrap.go +++ b/pkg/statistics/handle/bootstrap.go @@ -46,6 +46,11 @@ const initStatsStep = int64(500) 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 @@ -81,7 +86,7 @@ func (h *Handle) initStatsMeta4Chunk(is infoschema.InfoSchema, cache util.StatsC 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 d1208872bc03c..86ee4fd7e43f4 100644 --- a/pkg/statistics/handle/handletest/initstats/load_stats_test.go +++ b/pkg/statistics/handle/handletest/initstats/load_stats_test.go @@ -98,4 +98,5 @@ func testConcurrentlyInitStats(t *testing.T) { require.False(t, col.IsAllEvicted()) } } + require.Equal(t, int64(118), handle.GetMaxTidRecordForTest()) }