Skip to content

Commit

Permalink
feat: Set rawShardCount to be set only during the first walkShardsAnd…
Browse files Browse the repository at this point in the history
…Process
  • Loading branch information
devanbenz committed Oct 15, 2024
1 parent e2f16fe commit 4a56a49
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tsdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ func (s *Store) loadShards() error {
return err
}

// We use `rawShardCount` as a buffer size for channel creation below
rawShardCount := 0
walkShardsAndProcess := func(fn func(sfile *SeriesFile, idx interface{}, sh os.DirEntry, db os.DirEntry, rp os.DirEntry) error) error {
for _, db := range dbDirs {
rpDirs, err := s.getRetentionPolicyDirs(db, log)
Expand Down Expand Up @@ -416,7 +414,6 @@ func (s *Store) loadShards() error {
}

for _, sh := range shardDirs {
rawShardCount++
// Series file should not be in a retention policy but skip just in case.
if sh.Name() == SeriesFileDirectory {
log.Warn("Skipping series file in retention policy dir", zap.String("path", filepath.Join(s.path, db.Name(), rp.Name())))
Expand All @@ -433,8 +430,13 @@ func (s *Store) loadShards() error {
return nil
}

// We use `rawShardCount` as a buffer size for channel creation below.
// If there is no startupProgressMetrics count then this will be 0 creating a
// zero buffer channel.
rawShardCount := 0
if s.startupProgressMetrics != nil {
err := walkShardsAndProcess(func(sfile *SeriesFile, idx interface{}, sh os.DirEntry, db os.DirEntry, rp os.DirEntry) error {
rawShardCount++
s.startupProgressMetrics.AddShard()
return nil
})
Expand Down

0 comments on commit 4a56a49

Please sign in to comment.