thanos-io/thanos · error
open chunk reader for block %+v
Error message
open chunk reader for block %+v
What it means
WriteSeries opens a chunk reader for each source block via b.Chunks(); failure is wrapped as "open chunk reader for block %+v". The block's chunks file could not be opened or its reader could not be created.
Solutions
- Verify chunks/ directory exists with segment files matching meta.json (maxTime/minTime and segment list)
- Check permissions on the block directory and chunk files
- Remove or repair the corrupt block; if it is replicated, delete and re-sync from another replica
- Check filesystem/disk health (dmesg, smartctl) for underlying I/O errors
Defensive patterns
Strategy: validation
Validate before calling
for _, b := range readers {
meta := b.Meta()
chunksDir := filepath.Join(meta.ULID.String(), "chunks")
if fi, err := os.Stat(chunksDir); err != nil || !fi.IsDir() {
return fmt.Errorf("block %s chunks dir missing", meta.ULID)
}
} Try / catch
if err := comp.WriteSeries(ctx, readers, sWriter, progress); err != nil {
if strings.Contains(err.Error(), "open chunk reader") {
// identify block from wrapped message, validate/repair it
logger.Error("failed to open chunk reader", "err", err)
}
return err
} Prevention
- Verify meta.json segment ranges match actual chunks/ files before compaction
- Never manually edit or prune chunk segments inside block directories
- Re-sync corrupted blocks from replicas instead of repairing in place
When it happens
Trigger: b.Chunks() fails: missing/corrupt chunks/ directory or segment files, bad permissions, segment count mismatch with meta.json, or truncated chunk segments.
Common situations: Corrupted block after unclean shutdown or incomplete copy; block directory manually edited; storage volume errors; blocks restored from backup missing chunk segments.
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/da39549ed12f8fbb.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/compactv2/compactor.go:103
)
defer func() {
errs := tsdb_errors.NewMulti(err)
if cerr := tsdb_errors.CloseAll(closers); cerr != nil {
errs.Add(errors.Wrap(cerr, "close"))
}
err = errs.Err()
}()
for _, b := range readers {
indexr, err := b.Index()
if err != nil {
return errors.Wrapf(err, "open index reader for block %+v", b.Meta())
}
closers = append(closers, indexr)
chunkr, err := b.Chunks()
if err != nil {
return errors.Wrapf(err, "open chunk reader for block %+v", b.Meta())
}
closers = append(closers, chunkr)
sReaders = append(sReaders, seriesReader{ir: indexr, cr: chunkr})
}
symbols, set, err := compactSeries(ctx, sReaders...)
if err != nil {
return errors.Wrapf(err, "compact series from %v", func() string {
var metas []string
for _, m := range readers {
metas = append(metas, fmt.Sprintf("%v", m.Meta()))
}
return strings.Join(metas, ",")
}())
}
for _, m := range modifiers {
symbols, set = m.Modify(symbols, set, w.changeLogger, p)View on GitHub (pinned to 35b8b99117)