Skip to content

Commit

Permalink
fix: use new wg per parallelizer request (#1138)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolesnikovae authored Jun 8, 2022
1 parent 3ff1248 commit 7757c44
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/remotewrite/paralellizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
type Parallelizer struct {
log *logrus.Logger
ingesters []ingestion.Ingester
wg sync.WaitGroup
}

func NewParallelizer(log *logrus.Logger, ingesters ...ingestion.Ingester) *Parallelizer {
Expand All @@ -24,22 +23,23 @@ func NewParallelizer(log *logrus.Logger, ingesters ...ingestion.Ingester) *Paral
}

func (p *Parallelizer) Ingest(ctx context.Context, in *ingestion.IngestInput) error {
p.wg.Add(len(p.ingesters))
var wg sync.WaitGroup
wg.Add(len(p.ingesters))

// TODO(eh-am): add timeouts for each individual call
for _, putter := range p.ingesters {
// https://golang.org/doc/faq#closures_and_goroutines
putter := putter
go func(in *ingestion.IngestInput) {
defer p.wg.Done()
defer wg.Done()
err := putter.Ingest(ctx, in)
if err != nil {
p.log.Error("Failed to parallelize put: ", err)
}
}(in)
}

p.wg.Wait()
wg.Wait()

// if err := g.Wait(); err != nil {
// // swallow the error
Expand Down

0 comments on commit 7757c44

Please sign in to comment.