{"record":{"id":"05d4e6690b8c1fed","repo":"thanos-io/thanos","slug":"write-chunks-05d4e6","errorCode":null,"errorMessage":"write chunks","messagePattern":"write chunks","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compactv2/chunk_series_set.go","lineNumber":220,"sourceCode":"\t\tfor chksIter.Next() {\n\t\t\t// We are not iterating in streaming way over chunk as it's more efficient to do bulk write for index and\n\t\t\t// chunk file purposes.\n\t\t\tchks = append(chks, chksIter.At())\n\t\t}\n\n\t\tif chksIter.Err() != nil {\n\t\t\treturn errors.Wrap(chksIter.Err(), \"chunk iter\")\n\t\t}\n\n\t\t// Skip the series with all deleted chunks.\n\t\tif len(chks) == 0 {\n\t\t\t// All series will be ignored.\n\t\t\tp.SeriesProcessed()\n\t\t\tcontinue\n\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","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/compactv2/chunk_series_set.go#L202-L238","documentation":"sWriter.WriteChunks failed while bulk-writing the collected chunks of one series into the destination block's chunk file and index. Compaction uses bulk writes for efficiency; any failure here aborts writing the whole output block.","triggerScenarios":"write() calls sWriter.WriteChunks(chks...) after collecting a series' chunks; failure when writing chunk bytes to the destination block (segment file IO error, disk full, writer already closed/errored).","commonSituations":"Disk full or quota exceeded on the scratch volume, too many open files (ulimit), destination directory removed, an earlier silent write error poisoning the writer.","solutions":["Check free disk space and inode availability on the compactor's data directory; clean up partial compaction output.","Raise open-file limits (ulimit -n) if errors indicate fd exhaustion from many chunk segments.","Retry compaction from scratch — discard partial output block; writers are not resumable.","Check filesystem permissions on the output block directory."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if err := ensureWritableDir(outputBlockDir); err != nil {\n    return fmt.Errorf(\"output dir not writable: %w\", err)\n}\nif free := freeDiskBytes(dataDir); free < estimatedChunkBytes {\n    return fmt.Errorf(\"not enough disk for compaction output: need ~%d, have %d\", estimatedChunkBytes, free)\n}","typeGuard":null,"tryCatchPattern":"if err := WriteSeries(ctx, set, symbols); err != nil {\n    os.RemoveAll(partialOutputDir) // discard poisoned partial block\n    return err\n}","preventionTips":["Keep ample free space on the compactor scratch volume (monitor at 80%)","Raise ulimit -n for many chunk segments","Always delete partial output blocks after failed compaction","Run compaction output on local disk, not network filesystems"],"tags":["go","tsdb","chunk","write"],"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"}