Skip to content

Commit

Permalink
statistics: get right max table id when to init stats (#58280) (#58296)
Browse files Browse the repository at this point in the history
close #58284
  • Loading branch information
ti-chi-bot authored Dec 16, 2024
1 parent a763ffd commit 6351e9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/statistics/handle/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ func testConcurrentlyInitStats(t *testing.T) {
require.False(t, col.IsAllEvicted())
}
}
require.Equal(t, int64(118), handle.GetMaxTidRecordForTest())
}

0 comments on commit 6351e9e

Please sign in to comment.