{"record":{"id":"fba9c97ba2399b92","repo":"thanos-io/thanos","slug":"get-series-d","errorCode":null,"errorMessage":"get series %d","messagePattern":"get series (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compactv2/chunk_series_set.go","lineNumber":45,"sourceCode":"\tbufChks []chunks.Meta\n\tbufLbls labels.ScratchBuilder\n\n\tcurr *storage.ChunkSeriesEntry\n\terr  error\n}\n\nfunc newLazyPopulateChunkSeriesSet(sReader seriesReader, all index.Postings) *lazyPopulateChunkSeriesSet {\n\treturn &lazyPopulateChunkSeriesSet{sReader: sReader, all: all}\n}\n\nfunc (s *lazyPopulateChunkSeriesSet) Next() bool {\n\tfor s.all.Next() {\n\t\tif err := s.sReader.ir.Series(s.all.At(), &s.bufLbls, &s.bufChks); err != nil {\n\t\t\t// Postings may be stale. Skip if no underlying series exists.\n\t\t\tif errors.Cause(err) == storage.ErrNotFound {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\ts.err = errors.Wrapf(err, \"get series %d\", s.all.At())\n\t\t\treturn false\n\t\t}\n\n\t\tif len(s.bufChks) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor i := range s.bufChks {\n\t\t\ts.bufChks[i].Chunk = &lazyPopulatableChunk{cr: s.sReader.cr, m: &s.bufChks[i]}\n\t\t}\n\t\ts.curr = &storage.ChunkSeriesEntry{\n\t\t\tLset: s.bufLbls.Labels(),\n\t\t\tChunkIteratorFn: func(_ chunks.Iterator) chunks.Iterator {\n\t\t\t\treturn storage.NewListChunkSeriesIterator(s.bufChks...)\n\t\t\t},\n\t\t}\n\t\treturn true\n\t}","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/compactv2/chunk_series_set.go#L27-L63","documentation":"In compactor's chunkSeriesSet.Next, expanding a postings list ref into a series via the block's index reader (ir.Series) failed. The ref is wrapped into s.err and iteration stops. storage.ErrNotFound is explicitly tolerated (stale postings), so this error means any index-read failure other than a missing series.","triggerScenarios":"Calling Next() on the sorted chunk series set during compaction when ir.Series(ref, labels, chunks) returns a non-NotFound error: index decode failure, corrupt index file, IO error reading the block's index, or a race where the block is removed mid-compaction.","commonSituations":"Corrupted TSDB index after a crashed write or bad disk, block files deleted while compaction reads them, checksum failures on block index files, reading blocks from partially-uploaded object storage.","solutions":["Inspect the wrapped error: if it's an index checksum/decode failure, delete the corrupt block from storage (Thanos will repair by re-uploading or remove from view).","Ensure no concurrent deletion of the source blocks while compaction runs (single compactor per bucket prefix).","Retry the compaction; transient IO errors may clear, but re-open the block reader first (index readers may cache failures).","If it happens reproducibly after partial uploads, run a block repair/sync to restore consistent block data."],"exampleFix":"// handled inside the library already:\nif errors.Cause(err) == storage.ErrNotFound {\n    continue // stale postings tolerated\n}\ns.err = errors.Wrapf(err, \"get series %d\", s.all.At())\n// caller-side: check and propagate\nif set.Err() != nil {\n    return errors.Wrap(set.Err(), \"iterating series during compaction\")\n}","handlingStrategy":"try-catch","validationCode":"if err := verifyBlockIndex(blockDir); err != nil {\n    // exclude corrupt block from compaction set\n    skipBlock(id)\n}","typeGuard":"func isStalePostings(err error) bool {\n    return errors.Cause(err) == storage.ErrNotFound\n}","tryCatchPattern":"if err := runCompaction(ctx); err != nil {\n    var idxErr *indexErr\n    if errors.As(err, &idxErr) {\n        repairOrDeleteCorruptBlock(idxErr.BlockID)\n    }\n    return err\n}","preventionTips":["Run bucket verify/repair on blocks before compaction","Use a single compactor per bucket prefix to avoid mid-run block deletion","Alert on block checksum failures from object storage","Avoid deleting blocks while compaction is in progress"],"tags":["go","tsdb","index","corruption"],"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"}