From 583e746a826bf6fba7e089be81ebd0a210d717f6 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Thu, 10 Feb 2022 15:07:13 +0100 Subject: [PATCH 1/2] Fix error reported by asyncBlockWriter.addSeries() Signed-off-by: Marco Pracucci --- tsdb/async_block_writer.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tsdb/async_block_writer.go b/tsdb/async_block_writer.go index 47833def72..f569e48c56 100644 --- a/tsdb/async_block_writer.go +++ b/tsdb/async_block_writer.go @@ -2,7 +2,6 @@ package tsdb import ( "context" - "fmt" "github.com/pkg/errors" "go.uber.org/atomic" @@ -14,6 +13,10 @@ 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. @@ -111,7 +114,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 } } From f644c5867f3ea9ca01a9607c25949696e88a6795 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Thu, 10 Feb 2022 15:32:02 +0100 Subject: [PATCH 2/2] Make linter happy Signed-off-by: Marco Pracucci --- tsdb/async_block_writer.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tsdb/async_block_writer.go b/tsdb/async_block_writer.go index f569e48c56..0d5449a5f9 100644 --- a/tsdb/async_block_writer.go +++ b/tsdb/async_block_writer.go @@ -13,9 +13,7 @@ import ( "github.com/prometheus/prometheus/tsdb/chunks" ) -var ( - errAsyncBlockWriterNotRunning = errors.New("asyncBlockWriter doesn't run anymore") -) +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 {