Skip to content

Commit

Permalink
fix: Defer closing blocks iter after checking error from loadWorkForG…
Browse files Browse the repository at this point in the history
…ap (#12934)
  • Loading branch information
salvacorts committed May 10, 2024
1 parent a46d14f commit cb1f5d9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/bloomcompactor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ func (s *SimpleBloomController) buildGaps(
// to try and accelerate bloom creation
level.Debug(logger).Log("msg", "loading series and blocks for gap", "blocks", len(gap.blocks))
seriesItr, blocksIter, err := s.loadWorkForGap(ctx, table, tenant, plan.tsdb, gap)
if err != nil {
level.Error(logger).Log("msg", "failed to get series and blocks", "err", err)
return nil, errors.Wrap(err, "failed to get series and blocks")
}

// TODO(owen-d): more elegant error handling than sync.OnceFunc
closeBlocksIter := sync.OnceFunc(func() {
Expand All @@ -393,11 +397,6 @@ func (s *SimpleBloomController) buildGaps(
})
defer closeBlocksIter()

if err != nil {
level.Error(logger).Log("msg", "failed to get series and blocks", "err", err)
return nil, errors.Wrap(err, "failed to get series and blocks")
}

// Blocks are built consuming the series iterator. For observability, we wrap the series iterator
// with a counter iterator to count the number of times Next() is called on it.
// This is used to observe the number of series that are being processed.
Expand Down

0 comments on commit cb1f5d9

Please sign in to comment.