{"record":{"id":"cadb74aa207fcf67","repo":"thanos-io/thanos","slug":"iterate-populated-chunk-series-set","errorCode":null,"errorMessage":"iterate populated chunk series set","messagePattern":"iterate populated chunk series set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compactv2/chunk_series_set.go","lineNumber":235,"sourceCode":"\t\t}\n\n\t\tif err := sWriter.WriteChunks(chks...); err != nil {\n\t\t\treturn errors.Wrap(err, \"write chunks\")\n\t\t}\n\t\tif err := sWriter.AddSeries(ref, s.Labels(), chks...); err != nil {\n\t\t\treturn errors.Wrap(err, \"add series\")\n\t\t}\n\t\tfor _, chk := range chks {\n\t\t\t// ChunkPool is used by tsdb.OpenBlock BlockReader.\n\t\t\tif err := w.chunkPool.Put(chk.Chunk); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"put chunk\")\n\t\t\t}\n\t\t}\n\t\tref++\n\t\tp.SeriesProcessed()\n\t}\n\tif populatedSet.Err() != nil {\n\t\treturn errors.Wrap(populatedSet.Err(), \"iterate populated chunk series set\")\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":217,"sourceCodeEnd":240,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/compactv2/chunk_series_set.go#L217-L240","documentation":"After the full iteration loop, write() checks populatedSet.Err() and wraps it with \"iterate populated chunk series set\". This is a terminal aggregation error: the populated (materialized) chunk series set hit an error at some point during Next() (e.g. the earlier \"get series %d\" failure) that propagated to set-level state.","triggerScenarios":"WriteSeries finishes (or aborts) iteration over the populated set and populatedSet.Err() is non-nil — typically reflecting an index-read error stored by Next() during series expansion.","commonSituations":"Any mid-iteration index failure (corrupt index, missing block, IO error) surfaces here if not caught earlier; concurrent block deletion during compaction; object storage timeouts.","solutions":["Unwrap the cause to find the original per-series failure (often the same index-read error logged as 'get series %d').","Validate source blocks before compaction (thanos tools bucket verify) to catch corrupt indexes early.","Guarantee a single compactor owns the bucket/prefix so blocks aren't deleted mid-run.","Retry the compaction after transient storage errors; re-open block readers to clear cached error state."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if err := bucketVerify(ctx, srcBlockIDs); err != nil {\n    return fmt.Errorf(\"pre-compaction block verification failed: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := retry.Do(func() error {\n    return WriteSeries(ctx, buildPopulatedSet(), symbols)\n}, retry.OnRetry(func() { reopenBlockReaders() }), retry.RetryIf(isTransient), retry.Attempts(3))","preventionTips":["Run bucket verify on all source blocks before planning compaction","Ensure single compactor ownership per prefix so blocks aren't deleted mid-run","Re-open block readers between retries to clear cached iterator errors","Alert on per-series index read errors during compaction as early corruption signals"],"tags":["go","tsdb","iteration","compaction"],"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"}