thanos-io/thanos · error
rewrite block
Error message
rewrite block
What it means
The rewrite step inside block Repair failed while copying series/chunks into the new block (via rewrite with the ignore function). Indicates corrupt source index/chunks or an error from the chunk iterator; the partially written result is discarded.
Solutions
- Inspect the underlying rewrite error for the failing series
- Verify source block integrity
- Re-download the block and retry repair
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/block/index.go:472 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/67da7af5749688db.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/block/index.go:472
return resid, errors.Wrap(err, "open chunk writer")
}
defer runutil.CloseWithErrCapture(&err, chunkw, "repair chunk writer")
indexw, err := index.NewWriter(context.TODO(), filepath.Join(resdir, IndexFilename))
if err != nil {
return resid, errors.Wrap(err, "open index writer")
}
defer runutil.CloseWithErrCapture(&err, indexw, "repair index writer")
// TODO(fabxc): adapt so we properly handle the version once we update to an upstream
// that has multiple.
resmeta := *meta
resmeta.ULID = resid
resmeta.Stats = tsdb.BlockStats{} // Reset stats.
resmeta.Thanos.Source = source // Update source.
if err := rewrite(ctx, logger, indexr, chunkr, indexw, chunkw, &resmeta, ignoreChkFns); err != nil {
return resid, errors.Wrap(err, "rewrite block")
}
resmeta.Thanos.SegmentFiles = GetSegmentFiles(resdir)
if err := resmeta.WriteToDir(logger, resdir); err != nil {
return resid, err
}
// TSDB may rewrite metadata in bdir.
// TODO: This is not needed in newer TSDB code. See https://github.com/prometheus/tsdb/pull/637.
if err := meta.WriteToDir(logger, bdir); err != nil {
return resid, err
}
return resid, nil
}
var castagnoli = crc32.MakeTable(crc32.Castagnoli)
func IgnoreCompleteOutsideChunk(mint, maxt int64, _, curr *chunks.Meta) (bool, error) {
if curr.MinTime > maxt || curr.MaxTime < mint {
// "Complete" outsider. Ignore.View on GitHub (pinned to 35b8b99117)