{"record":{"id":"c83c120a655c6232","repo":"thanos-io/thanos","slug":"writing-series-from-v-to-v","errorCode":null,"errorMessage":"writing series from %v to %v","messagePattern":"writing series from (.+?) to (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/tools_bucket.go","lineNumber":1302,"sourceCode":"\t\t\t\t\tchangeLog = compactv2.NewChangeLog(f)\n\t\t\t\t\tlevel.Info(logger).Log(\"msg\", \"changelog will be available\", \"file\", filepath.Join(tbc.tmpDir, newID.String(), \"change.log\"))\n\t\t\t\t}\n\n\t\t\t\td, err := block.NewDiskWriter(ctx, logger, filepath.Join(tbc.tmpDir, newID.String()))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tvar comp *compactv2.Compactor\n\t\t\t\tif tbc.dryRun {\n\t\t\t\t\tcomp = compactv2.NewDryRun(tbc.tmpDir, logger, changeLog, chunkPool)\n\t\t\t\t} else {\n\t\t\t\t\tcomp = compactv2.New(tbc.tmpDir, logger, changeLog, chunkPool)\n\t\t\t\t}\n\n\t\t\t\tlevel.Info(logger).Log(\"msg\", \"starting rewrite for block\", \"source\", id, \"new\", newID, \"toDelete\", string(deletionsYaml), \"toRelabel\", string(relabelYaml))\n\t\t\t\tif err := comp.WriteSeries(ctx, []block.Reader{b}, d, p, modifiers...); err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"writing series from %v to %v\", id, newID)\n\t\t\t\t}\n\n\t\t\t\tif tbc.dryRun {\n\t\t\t\t\tlevel.Info(logger).Log(\"msg\", \"dry run finished. Changes should be printed to stderr\", \"Block ID\", id)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tlevel.Info(logger).Log(\"msg\", \"wrote new block after modifications; flushing\", \"source\", id, \"new\", newID)\n\t\t\t\tmeta.Stats, err = d.Flush()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"flush\")\n\t\t\t\t}\n\t\t\t\tif err := meta.WriteToDir(logger, filepath.Join(tbc.tmpDir, newID.String())); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tlevel.Info(logger).Log(\"msg\", \"uploading new block\", \"source\", id, \"new\", newID)\n\t\t\t\tif tbc.promBlocks {","sourceCodeStart":1284,"sourceCodeEnd":1320,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/tools_bucket.go#L1284-L1320","documentation":"Wraps compactv2 compactor WriteSeries failing while rewriting series from the source block into a new block. WriteSeries iterates the source index and writes filtered/relabeled series to a destination; failures come from relabel config application errors, malformed index data, context cancellation, or disk write errors during compaction.","triggerScenarios":"Invalid relabel config (bad regex, duplicate labels after replacement) passed via --rewrite; the source block index contains corrupt or out-of-order series; tmpDir runs out of space while writing; context canceled (Ctrl-C, timeout).","commonSituations":"Relabel regex with catastrophic backtracking or invalid syntax; rewriting very large blocks with insufficient tmpDir disk; series selectors in --delete that cause edge-case iteration issues; operator aborting the long-running rewrite.","solutions":["Validate the relabel YAML/regex with promtool before passing --rewrite.","Increase tmpDir disk space (point --tmp.dir to a large volume) and retry.","Check the wrapped cause: if it is context canceled, re-run without interruption; if index corruption, restore/verify the block first."],"exampleFix":"// before (invalid relabel regex)\n--rewrite=\"- action: replace\\n  regex: '(.*[ )'\\n  ...\"\n// after (validated)\n--rewrite=\"- action: replace\\n  regex: '(.*)'\\n  replacement: '$1'\\n  ...\"","handlingStrategy":"validation","validationCode":"if err := relabel.Validate(labels.FromStrings(\"__name__\", \"test\"), relabelCfgs...); err != nil {\n    return fmt.Errorf(\"invalid relabel config: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := comp.WriteSeries(ctx, readers, d, p, modifiers...); err != nil {\n    if errors.Is(err, context.Canceled) { return err }\n    return errors.Wrapf(err, \"writing series from %v to %v\", id, newID)\n}","preventionTips":["Validate relabel YAML and regexes with promtool before use","Give tmpDir ample disk for large blocks","Avoid interrupting long rewrites; use a screen/tmux session"],"tags":["thanos","compaction","relabel","rewrite"],"backgroundTag":"invalid-argument-value","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"}