Skip to content

Commit

Permalink
Fix poller waitgroup handling
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala committed Dec 11, 2023
1 parent dbdc21e commit 0b548ce
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tempodb/blocklist/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/go-kit/log/level"
"github.com/google/uuid"
opentracing "github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
spanlog "github.com/opentracing/opentracing-go/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
Expand Down Expand Up @@ -335,6 +336,7 @@ func (p *Poller) pollUnknown(
defer span.Finish()

var (
err error
errs []error
mtx sync.Mutex
bg = boundedwaitgroup.New(p.cfg.PollConcurrency)
Expand All @@ -343,8 +345,6 @@ func (p *Poller) pollUnknown(
)

for blockID, compacted := range unknownBlocks {
bg.Add(1)

// Avoid polling if we've already encountered an error
mtx.Lock()
if len(errs) > 0 {
Expand All @@ -353,6 +353,7 @@ func (p *Poller) pollUnknown(
}
mtx.Unlock()

bg.Add(1)
go func(id uuid.UUID, compacted bool) {
defer bg.Done()

Expand Down Expand Up @@ -383,8 +384,11 @@ func (p *Poller) pollUnknown(

if len(errs) > 0 {
metricTenantIndexErrors.WithLabelValues(tenantID).Inc()
// TODO: add span status on error
return nil, nil, errors.Join(errs...)
err = errors.Join(errs...)
ext.Error.Set(span, true)
span.SetTag("err", err)

return nil, nil, err
}

return newBlockList, newCompactedBlocklist, nil
Expand Down

0 comments on commit 0b548ce

Please sign in to comment.