{"record":{"id":"db19ed64e2d6a740","repo":"thanos-io/thanos","slug":"get-index-version","errorCode":null,"errorMessage":"get index version","messagePattern":"get index version","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/bucket.go","lineNumber":1287,"sourceCode":"\t\tChunks: next.chks,\n\t}), nil\n}\n\nfunc (b *blockSeriesClient) nextBatch(tenant string) error {\n\tstart := b.i\n\tend := min(start+uint64(b.batchSize), uint64(len(b.lazyPostings.postings)))\n\tb.i = end\n\n\tlazyExpandedPosting := b.lazyPostings.lazyExpanded()\n\tpostingsBatch := b.lazyPostings.postings[start:end]\n\tif len(postingsBatch) == 0 {\n\t\tb.hasMorePostings = false\n\t\tif lazyExpandedPosting {\n\t\t\t// No need to fetch index version again if lazy posting has 0 length.\n\t\t\tif len(b.lazyPostings.postings) > 0 {\n\t\t\t\tv, err := b.indexr.IndexVersion()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"get index version\")\n\t\t\t\t}\n\t\t\t\tif v >= 2 {\n\t\t\t\t\tfor i := range b.expandedPostings {\n\t\t\t\t\t\tb.expandedPostings[i] = b.expandedPostings[i] / 16\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tb.indexr.storeExpandedPostingsToCache(b.blockMatchers, index.NewListPostings(b.expandedPostings), len(b.expandedPostings), tenant)\n\t\t}\n\t\treturn nil\n\t}\n\n\tb.indexr.reset(len(postingsBatch))\n\tif !b.skipChunks {\n\t\tb.chunkr.reset()\n\t}\n\n\tif err := b.indexr.PreloadSeries(b.ctx, postingsBatch, b.bytesLimiter, b.tenant); err != nil {","sourceCodeStart":1269,"sourceCodeEnd":1305,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/bucket.go#L1269-L1305","documentation":"Wraps IndexReader.IndexVersion failure in blockSeriesClient.series preloading. The store reads the index format version to decide whether expanded-posting counts need scaling (v2 hash-based posting encoding). Failure means the index version could not be fetched from the block's index reader.","triggerScenarios":"Lazy expanded postings are enabled and non-empty (lazyExpandedPosting true with len(lazyPostings.postings) > 0), and b.indexr.IndexVersion() errors while fetching/decoding the index version from the block's index-header or index.","commonSituations":"Blocks written by very old Prometheus versions lacking version metadata, corrupted index-header, object-store errors while fetching index metadata during a lazy-postings query path.","solutions":["Delete and rebuild the block's index-header (remove the .index-header file; the store regenerates it).","Check the wrapped root error for object-store connectivity issues and retry.","Confirm the block's Prometheus/thanos index is a supported version (>= 1); re-compact or re-upload blocks from unsupported versions.","As a workaround, disable lazy expanded postings (store.lazy-expanded-posting-enabled=false) to skip this code path."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := query(ctx); err != nil && strings.Contains(err.Error(), \"get index version\") {\n\t// likely stale/corrupt index-header: trigger rebuild, then retry once\n\trebuildIndexHeader(blockID)\n\tif err := query(ctx); err != nil {\n\t\treturn fmt.Errorf(\"query failed after index-header rebuild: %w\", err)\n\t}\n}","preventionTips":["Keep all Thanos/Prometheus components on compatible, supported versions.","Periodically rebuild stale index-headers (store gateway does this on version mismatch).","Monitor object-store availability; transient fetch failures surface here first on the lazy-postings path.","Disable lazy expanded postings if this path proves unstable in your environment."],"tags":["index","lazy-postings","thanos-store"],"backgroundTag":"database-query-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"}