thanos-io/thanos · error

preloaded chunk too small, expecting

Error message

preloaded chunk too small, expecting %d, and failed to fetch full chunk

What it means

Raised in bucketChunkReader.load when the pooled pre-fetch range was too small for the chunk (fetched chunkLen < expected length) and the subsequent refetch of the full chunk also failed to obtain complete data. The chunk remains unavailable, so series loading for that chunk fails.

Solutions

  1. Retry the query; refetch failures are often transient object store errors
  2. Check chunk sizes exceeding estimatedMaxChunkSize and object store range behavior
  3. Verify bucket read permissions and network stability between store gateway and object storage
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/store/bucket.go:3817 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/9a934479d3c2723d. Report an issue: GitHub.

Appendix: source

Thrown at pkg/store/bucket.go:3817

			if err != nil {
				return errors.Wrap(err, "populate chunk")
			}
			stats.add(ChunksTouched, 1, int(chunkDataLen))
			continue
		}

		r.block.metrics.chunkRefetches.WithLabelValues(tenant).Inc()
		// If we didn't fetch enough data for the chunk, fetch more.
		fetchBegin = time.Now()
		// Read entire chunk into new buffer.
		// TODO: readChunkRange call could be avoided for any chunk but last in this particular part.
		if err := bytesLimiter.ReserveWithType(uint64(chunkLen), ChunksTouched); err != nil {
			return httpgrpc.Errorf(int(codes.ResourceExhausted), "exceeded bytes limit while fetching chunks: %s", err)
		}

		nb, err := r.block.readChunkRange(ctx, seq, int64(pIdx.offset), int64(chunkLen), []byteRange{{offset: 0, length: chunkLen}}, r.logger)
		if err != nil {
			return errors.Wrapf(err, "preloaded chunk too small, expecting %d, and failed to fetch full chunk", chunkLen)
		}
		if len(*nb) != chunkLen {
			return errors.Errorf("preloaded chunk too small, expecting %d", chunkLen)
		}

		stats.add(ChunksFetched, 1, len(*nb))
		c := rawChunk((*nb)[n:])
		err = populateChunk(&(res[pIdx.seriesEntry].chks[pIdx.chunk]), &c, aggrs, r.save, calculateChunkChecksum)
		if err != nil {
			r.block.chunkPool.Put(nb)
			return errors.Wrap(err, "populate chunk")
		}

		stats.add(ChunksTouched, 1, int(chunkDataLen))

		r.block.chunkPool.Put(nb)
	}
	return nil

View on GitHub (pinned to 35b8b99117)