Skip to content

Commit

Permalink
chore: fix logging issues in Store.loadShards (#25529)
Browse files Browse the repository at this point in the history
Fix reporting shards not opening correctly when they actually did.
Fix race condition with logging in loadShards.
  • Loading branch information
gwossum authored Nov 12, 2024
1 parent 0bc167b commit 65683bf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tsdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,13 @@ func (s *Store) loadShards() error {
loader := s.newShardLoader(sh.id, sh.db, sh.rp, false, withIndexVersion(indexVersion))

// Now perform the actual loading in parallel in separate goroutines.
go func() {
go func(log *zap.Logger) {
t.Take()
defer t.Release()

log := log.With(logger.Shard(sh.id), zap.String("path", loader.path))
start := time.Now()
res := loader.Load()
if res.err != nil {
if res.err == nil {
log.Info("Opened shard", zap.String("index_version", res.s.IndexType()), zap.Duration("duration", time.Since(start)))
} else {
log.Error("Failed to open shard", zap.Error(res.err))
Expand All @@ -584,7 +583,7 @@ func (s *Store) loadShards() error {
if s.startupProgressMetrics != nil {
s.startupProgressMetrics.CompletedShard()
}
}()
}(log.With(logger.Shard(sh.id), zap.String("path", loader.path)))
}

// Register shards serially as the parallel goroutines finish opening them.
Expand Down

0 comments on commit 65683bf

Please sign in to comment.