{"record":{"id":"280792de581d69d5","repo":"thanos-io/thanos","slug":"open-tombstone-reader-w","errorCode":null,"errorMessage":"open tombstone reader: %w","messagePattern":"open tombstone reader: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/expandedpostingscache/tsdb.go","lineNumber":54,"sourceCode":"\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,\n\t}, nil\n}\n\nfunc (q *blockBaseQuerier) LabelValues(ctx context.Context, name string, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {\n\tres, err := q.index.SortedLabelValues(ctx, name, hints, matchers...)\n\treturn res, nil, err","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/expandedpostingscache/tsdb.go#L36-L72","documentation":"newBlockBaseQuerier opens the block's tombstone reader via BlockReader.Tombstones() and wraps failure as 'open tombstone reader: %w', closing the previously opened index and chunk readers. A nil tombstone reader is tolerated (replaced by in-memory tombstones), so only an actual error surfaces here.","triggerScenarios":"NewCachedBlockChunkQuerier -> newBlockBaseQuerier; b.Tombstones() fails because the tombstones file is corrupt, unreadable, or the block directory changed underneath the reader.","commonSituations":"Concurrent deletion/compaction of the block while querying, corrupted tombstones file after a crash, permission or I/O problems on the block directory.","solutions":["Read the wrapped %w error for the specific file/IO cause","Verify block directory integrity and re-sync the block from object storage if corrupted","Avoid racing queries against blocks being deleted (check compaction/deletion timing)","Check filesystem permissions and health on the block storage path"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if _, err := os.Stat(filepath.Join(blockDir, \"tombstones\")); err != nil && !os.IsNotExist(err) { return err }","typeGuard":"func isTombOpenErr(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"open tombstone reader\")\n}","tryCatchPattern":"q, err := newBlockBaseQuerier(block, mint, maxt)\nif err != nil && strings.Contains(err.Error(), \"open tombstone reader\") {\n    // treat as corrupt block: drop local copy and retry from remote\n}","preventionTips":["Do not delete or rewrite tombstones files while queries are open","After an unclean shutdown, run tsdb verification/repair before serving queries","Ensure consistent permissions on block directories for the process user","Serialize deletions with queries through the block metadata/lease mechanism"],"tags":["tsdb","tombstones","storage"],"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"}