{"record":{"id":"7f8cc81339f4874b","repo":"thanos-io/thanos","slug":"open-chunk-reader-w","errorCode":null,"errorMessage":"open chunk reader: %w","messagePattern":"open chunk reader: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/expandedpostingscache/tsdb.go","lineNumber":48,"sourceCode":"\tblockID    ulid.ULID\n\tindex      prom_tsdb.IndexReader\n\tchunks     prom_tsdb.ChunkReader\n\ttombstones tombstones.Reader\n\n\tclosed bool\n\n\tmint, maxt int64\n}\n\nfunc newBlockBaseQuerier(b prom_tsdb.BlockReader, mint, maxt int64) (*blockBaseQuerier, error) {\n\tindexr, err := b.Index()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"open index reader: %w\", err)\n\t}\n\tchunkr, err := b.Chunks()\n\tif err != nil {\n\t\tindexr.Close()\n\t\treturn nil, fmt.Errorf(\"open chunk reader: %w\", err)\n\t}\n\ttombsr, err := b.Tombstones()\n\tif err != nil {\n\t\tindexr.Close()\n\t\tchunkr.Close()\n\t\treturn nil, fmt.Errorf(\"open tombstone reader: %w\", err)\n\t}\n\n\tif tombsr == nil {\n\t\ttombsr = tombstones.NewMemTombstones()\n\t}\n\treturn &blockBaseQuerier{\n\t\tblockID:    b.Meta().ULID,\n\t\tmint:       mint,\n\t\tmaxt:       maxt,\n\t\tindex:      indexr,\n\t\tchunks:     chunkr,\n\t\ttombstones: tombsr,","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/expandedpostingscache/tsdb.go#L30-L66","documentation":"newBlockBaseQuerier opens the block's chunk reader via BlockReader.Chunks() and wraps failure as 'open chunk reader: %w'; it first closes the already-opened index reader to avoid leaks. Chunk reader failures usually indicate corrupted or missing chunk segment files in the block directory.","triggerScenarios":"NewCachedBlockChunkQuerier -> newBlockBaseQuerier; b.Chunks() returns an error (missing chunk segments, truncated chunk file, checksum mismatch) after the index reader opened successfully.","commonSituations":"Disk full or disk corruption on the receive store path, block deleted/compacted concurrently while a query opened it, partial block restore, too many open files.","solutions":["Inspect the wrapped %w error to identify the failing chunk segment","Restore or re-download the affected block from object storage; delete the local corrupt copy","Check disk space and filesystem health (dmesg, df) on the storage volume","Increase file-descriptor limits if the cause is resource exhaustion"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"segs, err := filepath.Glob(filepath.Join(blockDir, \"chunks\", \"*\"))\nif err != nil || len(segs) == 0 { return errors.New(\"block has no chunk segments\") }","typeGuard":"func isChunkOpenErr(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"open chunk reader\")\n}","tryCatchPattern":"q, err := newBlockBaseQuerier(block, mint, maxt)\nif err != nil && strings.Contains(err.Error(), \"open chunk reader\") {\n    // re-fetch or re-download the block, then retry once\n}","preventionTips":["Keep the block directory immutable during queries; never mutate in place","Check disk space before compaction/ingest; ENOSPC corrupts chunk segments","Re-verify blocks downloaded from object storage (size + checksum)","Increase file-descriptor limits on high-fanout query paths"],"tags":["tsdb","storage","chunks"],"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"}