{"record":{"id":"b2c484bfad0debb6","repo":"thanos-io/thanos","slug":"generate-index-header","errorCode":null,"errorMessage":"generate index header","messagePattern":"generate index header","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/indexheader/binary_reader.go","lineNumber":590,"sourceCode":"\t\tbinfn := filepath.Join(dir, id.String(), block.IndexHeaderFilename)\n\t\tbr, err := newFileBinaryReader(binfn, postingOffsetsInMemSampling, metrics)\n\t\tif err == nil {\n\t\t\treturn br, nil\n\t\t}\n\n\t\tlevel.Debug(logger).Log(\"msg\", \"failed to read index-header from disk; recreating\", \"path\", binfn, \"err\", err)\n\n\t\tstart := time.Now()\n\t\tif _, err := WriteBinary(ctx, bkt, id, binfn, metrics.downloadDuration); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"write index header\")\n\t\t}\n\n\t\tlevel.Debug(logger).Log(\"msg\", \"built index-header file\", \"path\", binfn, \"elapsed\", time.Since(start))\n\t\treturn newFileBinaryReader(binfn, postingOffsetsInMemSampling, metrics)\n\t} else {\n\t\tbuf, err := WriteBinary(ctx, bkt, id, \"\", metrics.downloadDuration)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"generate index header\")\n\t\t}\n\n\t\treturn newMemoryBinaryReader(buf, postingOffsetsInMemSampling, metrics)\n\t}\n}\n\nfunc newMemoryBinaryReader(buf []byte, postingOffsetsInMemSampling int, metrics *BinaryReaderMetrics) (bw *BinaryReader, err error) {\n\tr := &BinaryReader{\n\t\tb:                           realByteSlice(buf),\n\t\tc:                           nil,\n\t\tpostings:                    map[string]*postingValueOffsets{},\n\t\tpostingOffsetsInMemSampling: postingOffsetsInMemSampling,\n\t\tmetrics:                     metrics,\n\t}\n\n\tif err := r.init(); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/indexheader/binary_reader.go#L572-L608","documentation":"In the in-memory path of loading an index-header (no cache filename configured), WriteBinary is called to generate the binary index-header bytes directly from the bucket. This error wraps any failure of that call, meaning the index-header could not be fetched/generated — root cause lies within WriteBinary (bucket access, malformed index, size limit).","triggerScenarios":"NewBinaryReader with cacheFilename == \"\": WriteBinary fails due to object-store read failure, block index not found in bucket, checksum failure, or the 64GiB size-limit error.","commonSituations":"Store gateway without disk cache configured hitting bucket throttling/outage; missing block index in bucket (partial upload/deletion); wrong bucket config pointing at a bucket missing the block.","solutions":["Check the wrapped cause: fix object-store connectivity/credentials if it is a download error.","Verify the block (meta.json + index) exists and is fully uploaded in the bucket; re-upload if truncated.","Configure a disk cache (cache path) so headers are fetched once and reused.","Check bucket rate limits (throttling) and add retries/backoff."],"exampleFix":"null","handlingStrategy":"retry","validationCode":"// verify the block index exists before generating the header\nok, err := bkt.Exists(ctx, path.Join(id.String(), meta.FilenameMeta))\nif err != nil || !ok {\n    return fmt.Errorf(\"block %s missing from bucket\", id)\n}","typeGuard":"null","tryCatchPattern":"_, err := NewBinaryReader(ctx, logger, bkt, \"\", id, sampling, metrics)\nif err != nil && strings.Contains(err.Error(), \"generate index header\") {\n    if isRetryable(err) {\n        return retryWithBackoff(ctx, 3, func() error {\n            _, err = NewBinaryReader(ctx, logger, bkt, \"\", id, sampling, metrics)\n            return err\n        })\n    }\n    return err\n}","preventionTips":["Configure a disk cache path on store-gateways to reduce bucket dependency.","Add retries with backoff for bucket reads (handles throttling).","Verify block uploads are complete (meta.json present) before queries.","Alert on bucket 5xx/throttling errors."],"tags":["object-storage","index-header","download","thanos"],"backgroundTag":"http-request-failed","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}