thanos-io/thanos · error
allocate chunk bytes
Error message
allocate chunk bytes
What it means
readChunkRange requests a pooled buffer of exactly chunkRanges.size() bytes from b.chunkPool before reading byte ranges into it. If the pool (or its allocator) cannot allocate the buffer, the error is wrapped as 'allocate chunk bytes'. The pool errors when the requested size exceeds its maximum chunk size limit.
Solutions
- Increase --store.grpc.series-max-chunk-bytes and/or chunk pool limits in store-gateway config so requested chunk sizes fit.
- Reduce query time range / series count or use downsampled blocks for long ranges.
- Verify chunk size in the block meta/index is sane; oversized values indicate corrupt index files.
- If a query legitimately needs huge chunks, split it into smaller sub-queries.
Example fix
// before (flag too small for block chunk sizes) thanos store-gateway --store.grpc.series-max-chunk-bytes=16000 // after thanos store-gateway --store.grpc.series-max-chunk-bytes=1048576
Defensive patterns
Strategy: validation
Validate before calling
if chunkRanges.size() > maxChunkPoolBytes {
return fmt.Errorf("requested chunk range %d exceeds pool max %d", chunkRanges.size(), maxChunkPoolBytes)
} Type guard
func fitsPool(size int, max int) bool { return size > 0 && size <= max } Try / catch
if err != nil && strings.Contains(err.Error(), "allocate chunk bytes") {
// fall back to non-pooled allocation or reject query with a clear message
} Prevention
- Set --store.grpc.series-max-chunk-bytes >= block chunk sizes
- Tune max-chunk-pool-bytes to match workload
- Use downsampled blocks for long-range queries
When it happens
Trigger: chunkPool.Get(chunkRanges.size()) fails because the requested range size exceeds the pool's max size — i.e. the chunk ranges computed for the query are larger than the configured max-chunk-pool-bytes / max size per chunk.
Common situations: Very large chunk ranges requested due to huge queries or downsampling misconfiguration, max-chunk-pool-bytes set too low relative to block chunk sizes, corrupted index claiming oversized ranges.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — 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/1f62b2eb8b1e3043.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/store/bucket.go:2542
return buf.Bytes(), nil
}
func (b *bucketBlock) readChunkRange(ctx context.Context, seq int, off, length int64, chunkRanges byteRanges, logger log.Logger) (*[]byte, error) {
if seq < 0 || seq >= len(b.chunkObjs) {
return nil, errors.Errorf("unknown segment file for index %d", seq)
}
// Get a reader for the required range.
reader, err := b.bkt.GetRange(ctx, b.chunkObjs[seq], off, length)
if err != nil {
return nil, errors.Wrap(err, "get range reader")
}
defer runutil.CloseWithLogOnErr(logger, reader, "readChunkRange close range reader")
// Get a buffer from the pool.
chunkBuffer, err := b.chunkPool.Get(chunkRanges.size())
if err != nil {
return nil, errors.Wrap(err, "allocate chunk bytes")
}
*chunkBuffer, err = readByteRanges(reader, *chunkBuffer, chunkRanges)
if err != nil {
return nil, err
}
return chunkBuffer, nil
}
func (b *bucketBlock) chunkRangeReader(ctx context.Context, seq int, off, length int64) (io.ReadCloser, error) {
if seq < 0 || seq >= len(b.chunkObjs) {
return nil, errors.Errorf("unknown segment file for index %d", seq)
}
return b.bkt.GetRange(ctx, b.chunkObjs[seq], off, length)
}
View on GitHub (pinned to 35b8b99117)