thanos-io/thanos · error
write chunks
Error message
write chunks
What it means
sWriter.WriteChunks failed while bulk-writing the collected chunks of one series into the destination block's chunk file and index. Compaction uses bulk writes for efficiency; any failure here aborts writing the whole output block.
Solutions
- Check free disk space and inode availability on the compactor's data directory; clean up partial compaction output.
- Raise open-file limits (ulimit -n) if errors indicate fd exhaustion from many chunk segments.
- Retry compaction from scratch — discard partial output block; writers are not resumable.
- Check filesystem permissions on the output block directory.
Defensive patterns
Strategy: validation
Validate before calling
if err := ensureWritableDir(outputBlockDir); err != nil {
return fmt.Errorf("output dir not writable: %w", err)
}
if free := freeDiskBytes(dataDir); free < estimatedChunkBytes {
return fmt.Errorf("not enough disk for compaction output: need ~%d, have %d", estimatedChunkBytes, free)
} Try / catch
if err := WriteSeries(ctx, set, symbols); err != nil {
os.RemoveAll(partialOutputDir) // discard poisoned partial block
return err
} Prevention
- Keep ample free space on the compactor scratch volume (monitor at 80%)
- Raise ulimit -n for many chunk segments
- Always delete partial output blocks after failed compaction
- Run compaction output on local disk, not network filesystems
When it happens
Trigger: write() calls sWriter.WriteChunks(chks...) after collecting a series' chunks; failure when writing chunk bytes to the destination block (segment file IO error, disk full, writer already closed/errored).
Common situations: Disk full or quota exceeded on the scratch volume, too many open files (ulimit), destination directory removed, an earlier silent write error poisoning the writer.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/05d4e6690b8c1fed.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/compactv2/chunk_series_set.go:220
for chksIter.Next() {
// We are not iterating in streaming way over chunk as it's more efficient to do bulk write for index and
// chunk file purposes.
chks = append(chks, chksIter.At())
}
if chksIter.Err() != nil {
return errors.Wrap(chksIter.Err(), "chunk iter")
}
// Skip the series with all deleted chunks.
if len(chks) == 0 {
// All series will be ignored.
p.SeriesProcessed()
continue
}
if err := sWriter.WriteChunks(chks...); err != nil {
return errors.Wrap(err, "write chunks")
}
if err := sWriter.AddSeries(ref, s.Labels(), chks...); err != nil {
return errors.Wrap(err, "add series")
}
for _, chk := range chks {
// ChunkPool is used by tsdb.OpenBlock BlockReader.
if err := w.chunkPool.Put(chk.Chunk); err != nil {
return errors.Wrap(err, "put chunk")
}
}
ref++
p.SeriesProcessed()
}
if populatedSet.Err() != nil {
return errors.Wrap(populatedSet.Err(), "iterate populated chunk series set")
}
return nilView on GitHub (pinned to 35b8b99117)