Log WAL segment loading time (#16336)

Improve readability of "WAL segment loaded" by logging the duration
of each load. This helps make it easier to spot slow WAL file load
times.

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
Ben Kochie 2025-03-31 06:05:14 +02:00 committed by GitHub
parent 74a1d96c72
commit a721daf981
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -784,6 +784,7 @@ func (h *Head) Init(minValidTime int64) error {
}
// Backfill segments from the most recent checkpoint onwards.
for i := startFrom; i <= endAt; i++ {
walSegmentStart := time.Now()
s, err := wlog.OpenReadSegment(wlog.SegmentName(h.wal.Dir(), i))
if err != nil {
return fmt.Errorf("open WAL segment: %d: %w", i, err)
@ -808,7 +809,7 @@ func (h *Head) Init(minValidTime int64) error {
if err != nil {
return err
}
h.logger.Info("WAL segment loaded", "segment", i, "maxSegment", endAt)
h.logger.Info("WAL segment loaded", "segment", i, "maxSegment", endAt, "duration", time.Since(walSegmentStart))
h.updateWALReplayStatusRead(i)
}
walReplayDuration := time.Since(walReplayStart)