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 69fe249
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 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 @@ -227,7 +228,6 @@ func (p *Poller) pollTenantAndCreateIndex(
// if we're here then we have been configured to be a tenant index builder OR
// there was a failure to pull the tenant index and we are configured to fall
// back to polling.
metricTenantIndexBuilder.WithLabelValues(tenantID).Set(1)
blocklist, compactedBlocklist, err := p.pollTenantBlocks(derivedCtx, tenantID, previous)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -335,6 +335,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 +344,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 +352,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 +383,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 69fe249

Please sign in to comment.