thanos-io/thanos · error

populateWithDelChunkSeriesIterator: unexpected empty chunk…

Error message

populateWithDelChunkSeriesIterator: unexpected empty chunk found while rewriting chunk

What it means

While re-encoding a chunk under deletion modifiers, the iterator reached ValNone with no iterator error and an empty chunk was produced. The code explicitly treats this as an invariant violation: fully-deleted chunks should have been filtered out before this iterator, so an empty rewritten chunk means internal state is wrong.

Solutions

  1. Ensure fully-deleted chunks are filtered before populating (run vertical compaction/tombstone cleanup, or check the deletion filtering in the modifier pipeline)
  2. Check the modifier's deletion ranges — make sure minTime/maxTime handling drops chunks fully covered by deletions
  3. Report/inspect as a bug if it reproduces with a specific modifier range; work around by adjusting the deletion window
  4. Rerun compaction after tombstone cleanup (e.g. after a clean compaction level removes tombstones)
Defensive patterns

Strategy: validation

Validate before calling

// Drop chunks fully covered by the deletion range before rewriting
chunks = filterOutFullyDeleted(chunks, delMinTime, delMaxTime)

Prevention

When it happens

Trigger: currDelIter.Next() == ValNone, currDelIter.Err() == nil, and err happens to be nil when wrapped — i.e. a chunk whose samples were all deleted (fully tombstoned) still reached the rewriting iterator instead of being dropped earlier.

Common situations: Deletion/time-range modifier selecting a window covering an entire chunk but the pre-filter not removing that chunk; block with tombstones not previously cleaned; edge-case chunk boundary conditions with modifiers.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at pkg/compactv2/modifiers.go:334

		return true
	}

	// Re-encode the chunk if iterator is provider. This means that it has some samples to be deleted or chunk is opened.
	newChunk := chunkenc.NewXORChunk()
	app, err := newChunk.Appender()
	if err != nil {
		p.err = err
		return false
	}

	if p.currDelIter.Next() == chunkenc.ValNone {
		if err := p.currDelIter.Err(); err != nil {
			p.err = errors.Wrap(err, "iterate chunk while re-encoding")
			return false
		}

		// Empty chunk, this should not happen, as we assume full deletions being filtered before this iterator.
		p.err = errors.Wrap(err, "populateWithDelChunkSeriesIterator: unexpected empty chunk found while rewriting chunk")
		return false
	}

	t, v := p.currDelIter.At()
	p.curr.MinTime = t
	app.Append(t, v)

	for p.currDelIter.Next() != chunkenc.ValNone {
		t, v = p.currDelIter.At()
		app.Append(t, v)
	}
	if err := p.currDelIter.Err(); err != nil {
		p.err = errors.Wrap(err, "iterate chunk while re-encoding")
		return false
	}

	p.curr.Chunk = newChunk
	p.curr.MaxTime = t

View on GitHub (pinned to 35b8b99117)