{"record":{"id":"da39549ed12f8fbb","repo":"thanos-io/thanos","slug":"open-chunk-reader-for-block-v","errorCode":null,"errorMessage":"open chunk reader for block %+v","messagePattern":"open chunk reader for block %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compactv2/compactor.go","lineNumber":103,"sourceCode":"\t)\n\tdefer func() {\n\t\terrs := tsdb_errors.NewMulti(err)\n\t\tif cerr := tsdb_errors.CloseAll(closers); cerr != nil {\n\t\t\terrs.Add(errors.Wrap(cerr, \"close\"))\n\t\t}\n\t\terr = errs.Err()\n\t}()\n\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)","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/compactv2/compactor.go#L85-L121","documentation":"WriteSeries opens a chunk reader for each source block via b.Chunks(); failure is wrapped as \"open chunk reader for block %+v\". The block's chunks file could not be opened or its reader could not be created.","triggerScenarios":"b.Chunks() fails: missing/corrupt chunks/ directory or segment files, bad permissions, segment count mismatch with meta.json, or truncated chunk segments.","commonSituations":"Corrupted block after unclean shutdown or incomplete copy; block directory manually edited; storage volume errors; blocks restored from backup missing chunk segments.","solutions":["Verify chunks/ directory exists with segment files matching meta.json (maxTime/minTime and segment list)","Check permissions on the block directory and chunk files","Remove or repair the corrupt block; if it is replicated, delete and re-sync from another replica","Check filesystem/disk health (dmesg, smartctl) for underlying I/O errors"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for _, b := range readers {\n    meta := b.Meta()\n    chunksDir := filepath.Join(meta.ULID.String(), \"chunks\")\n    if fi, err := os.Stat(chunksDir); err != nil || !fi.IsDir() {\n        return fmt.Errorf(\"block %s chunks dir missing\", meta.ULID)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := comp.WriteSeries(ctx, readers, sWriter, progress); err != nil {\n    if strings.Contains(err.Error(), \"open chunk reader\") {\n        // identify block from wrapped message, validate/repair it\n        logger.Error(\"failed to open chunk reader\", \"err\", err)\n    }\n    return err\n}","preventionTips":["Verify meta.json segment ranges match actual chunks/ files before compaction","Never manually edit or prune chunk segments inside block directories","Re-sync corrupted blocks from replicas instead of repairing in place"],"tags":["go","tsdb","block","io"],"backgroundTag":"file-open-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"}