{"record":{"id":"d2e8f2171659359e","repo":"thanos-io/thanos","slug":"write","errorCode":null,"errorMessage":"write","messagePattern":"write","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compactv2/compactor.go","lineNumber":149,"sourceCode":"\t\t\t}\n\n\t\t\ts := set.At()\n\t\t\titer := s.Iterator(nil)\n\t\t\tfor iter.Next() {\n\t\t\t}\n\t\t\tif err := iter.Err(); err != nil {\n\t\t\t\tlevel.Error(w.logger).Log(\"msg\", \"error while iterating over chunks\", \"series\", s.Labels(), \"err\", err)\n\t\t\t}\n\t\t\tp.SeriesProcessed()\n\t\t}\n\t\tif err := set.Err(); err != nil {\n\t\t\tlevel.Error(w.logger).Log(\"msg\", \"error while iterating over set\", \"err\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\tif err := w.write(ctx, symbols, set, sWriter, p); err != nil {\n\t\treturn errors.Wrap(err, \"write\")\n\t}\n\treturn nil\n}\n\n// compactSeries compacts blocks' series into symbols and one ChunkSeriesSet with lazy populating chunks.\nfunc compactSeries(ctx context.Context, sReaders ...seriesReader) (symbols index.StringIter, set storage.ChunkSeriesSet, _ error) {\n\tif len(sReaders) == 0 {\n\t\treturn nil, nil, errors.New(\"cannot populate block from no readers\")\n\t}\n\n\tvar sets []storage.ChunkSeriesSet\n\tfor i, r := range sReaders {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil, nil, ctx.Err()\n\t\tdefault:\n\t\t}\n","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/compactv2/compactor.go#L131-L167","documentation":"After compaction produces the merged series set, WriteSeries writes the result to the destination block writer via w.write(); failure is wrapped as \"write\". This is a failure while actually materializing the output block (symbols, series, chunks).","triggerScenarios":"w.write fails: destination writer (block.Writer) errors — disk full, I/O error writing segment/symbol/index files, append/encoding failures on individual chunks, or progress-reporting/abort checks inside write.","commonSituations":"Out of disk space on the data volume during compaction; failing disk; output writer pointing to an invalid or closed sink; unencodable chunk data produced by modifiers.","solutions":["Check free disk space on the volume receiving the new block and clean up if full","Inspect the wrapped inner error for the specific file or chunk encoding that failed","Verify the destination block.Writer was correctly opened (TempDir/ directory writable)","Rerun compaction; if it fails repeatedly on the same chunk, investigate the source chunk data"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure destination has free space before compaction\nif err := checkFreeSpace(destDir, estimatedSize); err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := comp.WriteSeries(ctx, readers, sWriter, progress); err != nil {\n    if strings.Contains(err.Error(), \"write\") {\n        logger.Error(\"failed writing compacted block\", \"err\", err)\n        // clean partial temp dir of destination writer\n    }\n    return err\n}","preventionTips":["Monitor disk free space on compaction volumes","Alert on I/O errors in system logs","Always clean up temp output directories after failed compactions","Validate chunk encodings expected by the destination writer"],"tags":["go","tsdb","write","io"],"backgroundTag":"file-write-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"}