{"record":{"id":"30b5c7526387fb59","repo":"thanos-io/thanos","slug":"lazy-load-index-header-for-block-s","errorCode":null,"errorMessage":"lazy load index-header for block %s","messagePattern":"lazy load index-header for block (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/indexheader/lazy_binary_reader.go","lineNumber":273,"sourceCode":"\t}()\n\n\t// Ensure none else tried to load it in the meanwhile.\n\tif r.reader != nil {\n\t\treturn nil\n\t}\n\tif r.readerErr != nil {\n\t\treturn r.readerErr\n\t}\n\n\tlevel.Debug(r.logger).Log(\"msg\", \"lazy loading index-header\", \"block\", r.id)\n\tr.metrics.loadCount.Inc()\n\tstartTime := time.Now()\n\n\treader, err := NewBinaryReader(r.ctx, r.logger, r.bkt, r.dir, r.id, r.postingOffsetsInMemSampling, r.binaryReaderMetrics)\n\tif err != nil {\n\t\tr.metrics.loadFailedCount.Inc()\n\t\tr.readerErr = err\n\t\treturn errors.Wrapf(err, \"lazy load index-header for block %s\", r.id)\n\t}\n\n\tr.reader = reader\n\tlevel.Debug(r.logger).Log(\"msg\", \"lazy loaded index-header\", \"block\", r.id, \"elapsed\", time.Since(startTime))\n\tr.metrics.loadDuration.Observe(time.Since(startTime).Seconds())\n\n\treturn nil\n}\n\n// unloadIfIdleSince closes underlying BinaryReader if the reader is idle since given time (as unix nano). If idleSince is 0,\n// the check on the last usage is skipped. Calling this function on a already unloaded reader is a no-op.\nfunc (r *LazyBinaryReader) unloadIfIdleSince(ts int64) error {\n\tr.readerMx.Lock()\n\tdefer r.readerMx.Unlock()\n\n\t// Nothing to do if already unloaded.\n\tif r.reader == nil {\n\t\treturn nil","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/indexheader/lazy_binary_reader.go#L255-L291","documentation":"LazyBinaryReader.load failed creating the underlying BinaryReader (downloading/reading the index header from the bucket on first lazy use). The error is cached in readerErr so subsequent reads fail fast until reload.","triggerScenarios":"Thrown at pkg/block/indexheader/lazy_binary_reader.go:273 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check bucket access for the block's index-header file","Verify the index-header exists or regenerate it","Clear cached error by reloading the block"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}