Skip to content

Commit

Permalink
Merge pull request #133 from grafana/fix-error-reported-by-asyncblock…
Browse files Browse the repository at this point in the history
…writer

Fix error reported by asyncBlockWriter.addSeries()
  • Loading branch information
pracucci authored Feb 10, 2022
2 parents cd86e92 + f644c58 commit f8e3195
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tsdb/async_block_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tsdb

import (
"context"
"fmt"

"github.com/pkg/errors"
"go.uber.org/atomic"
Expand All @@ -14,6 +13,8 @@ import (
"github.com/prometheus/prometheus/tsdb/chunks"
)

var errAsyncBlockWriterNotRunning = errors.New("asyncBlockWriter doesn't run anymore")

// asyncBlockWriter runs a background goroutine that writes series and chunks to the block asynchronously.
type asyncBlockWriter struct {
chunkPool chunkenc.Pool // Where to return chunks after writing.
Expand Down Expand Up @@ -111,7 +112,14 @@ func (bw *asyncBlockWriter) addSeries(lbls labels.Labels, chks []chunks.Meta) er
if ok {
bw.result = result
}
return fmt.Errorf("asyncBlockWriter doesn't run anymore")

// If the writer isn't running anymore because of an error occurred in loop()
// then we should return that error too, otherwise it may be never reported
// and we'll never know the actual root cause.
if bw.result.err != nil {
return errors.Wrap(bw.result.err, errAsyncBlockWriterNotRunning.Error())
}
return errAsyncBlockWriterNotRunning
}
}

Expand Down

0 comments on commit f8e3195

Please sign in to comment.