{"record":{"id":"a91669326f5b590b","repo":"thanos-io/thanos","slug":"compact-series-from-v","errorCode":null,"errorMessage":"compact series from %v","messagePattern":"compact series from (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compactv2/compactor.go","lineNumber":111,"sourceCode":"\n\tfor _, b := range readers {\n\t\tindexr, err := b.Index()\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"open index reader for block %+v\", b.Meta())\n\t\t}\n\t\tclosers = append(closers, indexr)\n\n\t\tchunkr, err := b.Chunks()\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"open chunk reader for block %+v\", b.Meta())\n\t\t}\n\t\tclosers = append(closers, chunkr)\n\t\tsReaders = append(sReaders, seriesReader{ir: indexr, cr: chunkr})\n\t}\n\n\tsymbols, set, err := compactSeries(ctx, sReaders...)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"compact series from %v\", func() string {\n\t\t\tvar metas []string\n\t\t\tfor _, m := range readers {\n\t\t\t\tmetas = append(metas, fmt.Sprintf(\"%v\", m.Meta()))\n\t\t\t}\n\t\t\treturn strings.Join(metas, \",\")\n\t\t}())\n\t}\n\n\tfor _, m := range modifiers {\n\t\tsymbols, set = m.Modify(symbols, set, w.changeLogger, p)\n\t}\n\n\tif w.dryRun {\n\t\t// Even for dry run, we need to exhaust iterators to see potential changes.\n\t\tfor set.Next() {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn ctx.Err()","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/compactv2/compactor.go#L93-L129","documentation":"After opening readers, WriteSeries merges all blocks' series via compactSeries. Any error there is wrapped as \"compact series from <metas>\" where metas is a comma-joined list of all source block metadata. This indicates a failure while iterating/re-encoding series across the input blocks.","triggerScenarios":"compactSeries fails: a source block's symbol/series/chunk iterator errors mid-iteration (corrupt index or chunk data), context cancellation during iteration, or internal population errors in the merged series set.","commonSituations":"Corrupted block content discovered only at read time; two overlapping blocks with corrupt deduplication inputs; compaction cancelled by shutdown (context deadline) racing with iteration errors.","solutions":["Inspect the inner wrapped error to identify which source block's iterator failed and validate/repair that block","Check whether the error is context.Canceled/DeadlineExceeded from a shutdown — if so, rerun compaction","Delete or quarantine corrupt blocks and re-sync from replicas","Check TSDB logs for prior corruption warnings for these block ULIDs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check context is still alive before starting long compactions\nif err := ctx.Err(); err != nil { return err }","typeGuard":null,"tryCatchPattern":"if err := comp.WriteSeries(ctx, readers, sWriter, progress); err != nil {\n    if errors.Is(ctx.Err(), context.Canceled) {\n        return ctx.Err() // shutdown, retry later\n    }\n    if strings.Contains(err.Error(), \"compact series from\") {\n        logger.Error(\"series compaction failed\", \"err\", err)\n    }\n    return err\n}","preventionTips":["Distinguish context cancellation from data errors before treating as corruption","Validate blocks before compaction to catch corrupt data early","Keep replicas so corrupt source blocks can be re-fetched"],"tags":["go","tsdb","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"}