{"record":{"id":"3b70f0a09fbfa2c3","repo":"thanos-io/thanos","slug":"open-index-reader-for-block-v","errorCode":null,"errorMessage":"open index reader for block %+v","messagePattern":"open index reader for block %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compactv2/compactor.go","lineNumber":97,"sourceCode":"\t\treturn errors.New(\"cannot write from no readers\")\n\t}\n\n\tvar (\n\t\tsReaders []seriesReader\n\t\tclosers  []io.Closer\n\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}","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/compactv2/compactor.go#L79-L115","documentation":"WriteSeries opens an index reader for each source block via b.Index(); failure is wrapped as \"open index reader for block %+v\" with the block metadata. This means the block's index file could not be opened or its reader could not be constructed.","triggerScenarios":"b.Index() returns an error: index file missing/corrupt in the block directory, wrong permissions, block mid-deletion, or an index format the reader rejects.","commonSituations":"Corrupted TSDB block after crash or truncated download/copy; block directory being deleted concurrently by another process; manually copied blocks missing index file; permission problems on data volume.","solutions":["Verify the block directory contains a readable index file (file size > 0, permissions OK)","Check for concurrent deletion — ensure the block is not being removed by another compaction/retention process","Run TSDB block verification/repair or delete the corrupt block and let TSDB re-fetch/rebuild if it is a replica","Check disk health and filesystem errors in system logs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for _, b := range readers {\n    meta := b.Meta()\n    if fi, err := os.Stat(filepath.Join(meta.ULID.String(), \"index\")); err != nil || fi.Size() == 0 {\n        return fmt.Errorf(\"block %s index missing or empty\", meta.ULID)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := comp.WriteSeries(ctx, readers, sWriter, progress); err != nil {\n    var target error\n    if strings.Contains(err.Error(), \"open index reader\") {\n        // quarantine/re-sync the offending block reported in the message\n        logger.Error(\"failed to open index reader\", \"err\", err)\n    }\n    return err\n}","preventionTips":["Verify block directories (index file present, non-empty) before compaction","Avoid copying blocks with cp/rsync while they are being written","Use atomic rename when installing blocks","Monitor for concurrent deletion processes touching the same block"],"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"}