thanos-io/thanos · error

compact series from

Error message

compact series from %v

What it means

After opening readers, WriteSeries merges all blocks' series via compactSeries. Any error there is wrapped as "compact series from <metas>" where metas is a comma-joined list of all source block metadata. This indicates a failure while iterating/re-encoding series across the input blocks.

Solutions

  1. Inspect the inner wrapped error to identify which source block's iterator failed and validate/repair that block
  2. Check whether the error is context.Canceled/DeadlineExceeded from a shutdown — if so, rerun compaction
  3. Delete or quarantine corrupt blocks and re-sync from replicas
  4. Check TSDB logs for prior corruption warnings for these block ULIDs
Defensive patterns

Strategy: try-catch

Validate before calling

// Check context is still alive before starting long compactions
if err := ctx.Err(); err != nil { return err }

Try / catch

if err := comp.WriteSeries(ctx, readers, sWriter, progress); err != nil {
    if errors.Is(ctx.Err(), context.Canceled) {
        return ctx.Err() // shutdown, retry later
    }
    if strings.Contains(err.Error(), "compact series from") {
        logger.Error("series compaction failed", "err", err)
    }
    return err
}

Prevention

When it happens

Trigger: compactSeries fails: a source block's symbol/series/chunk iterator errors mid-iteration (corrupt index or chunk data), context cancellation during iteration, or internal population errors in the merged series set.

Common situations: Corrupted block content discovered only at read time; two overlapping blocks with corrupt deduplication inputs; compaction cancelled by shutdown (context deadline) racing with iteration errors.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/a91669326f5b590b. Report an issue: GitHub.

Appendix: source

Thrown at pkg/compactv2/compactor.go:111

	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)
	}

	if w.dryRun {
		// Even for dry run, we need to exhaust iterators to see potential changes.
		for set.Next() {
			select {
			case <-ctx.Done():
				return ctx.Err()

View on GitHub (pinned to 35b8b99117)