thanos-io/thanos · error
add series
Error message
add series
What it means
WriteSeries rejects the series because the streamedBlockWriter has already been finalized (Close called) or an earlier error set ignoreFinalize, so the block directory is closed for writes. It fires when Downsample keeps feeding series after the writer's lifecycle has ended.
Solutions
- Ensure all WriteSeries calls happen before Close and stop writing once finalize started.
- Check the earlier error that set ignoreFinalize instead of retrying writes.
- Return the error to the caller (Downsample) and abort the current block.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/compact/downsample/streamed_block_writer.go:127 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/4dbdf7989addf8e3.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/compact/downsample/streamed_block_writer.go:127
// labelsValues sets and memPostings to be written on the finalize state in the end of downsampling process.
func (w *streamedBlockWriter) WriteSeries(lset labels.Labels, chunks []chunks.Meta) error {
if w.finalized || w.ignoreFinalize {
return errors.New("series can't be added, writers has been closed or internal error happened")
}
if len(chunks) == 0 {
level.Warn(w.logger).Log("msg", "empty chunks happened, skip series", "series", strings.ReplaceAll(lset.String(), "\"", "'"))
return nil
}
if err := w.chunkWriter.WriteChunks(chunks...); err != nil {
w.ignoreFinalize = true
return errors.Wrap(err, "add chunks")
}
if err := w.indexWriter.AddSeries(w.seriesRefs, lset, chunks...); err != nil {
w.ignoreFinalize = true
return errors.Wrap(err, "add series")
}
w.seriesRefs++
w.totalChunks += uint64(len(chunks))
for i := range chunks {
w.totalSamples += uint64(chunks[i].Chunk.NumSamples())
}
return nil
}
// Close calls finalizer to complete index and meta files and closes all io.CLoser writers.
// Idempotent.
func (w *streamedBlockWriter) Close() error {
if w.finalized {
return nil
}View on GitHub (pinned to 35b8b99117)