{"record":{"id":"fce22d6cc0b83f9d","repo":"thanos-io/thanos","slug":"open-block-s","errorCode":null,"errorMessage":"open block %s","messagePattern":"open block (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/downsample.go","lineNumber":381,"sourceCode":"\t}\n\tlevel.Info(logger).Log(\"msg\", \"downloaded block\", \"id\", m.ULID, \"duration\", time.Since(begin), \"duration_ms\", time.Since(begin).Milliseconds())\n\n\tif err := block.VerifyIndex(ctx, logger, filepath.Join(bdir, block.IndexFilename), m.MinTime, m.MaxTime); err != nil && !acceptMalformedIndex {\n\t\treturn errors.Wrap(err, \"input block index not valid\")\n\t}\n\n\tbegin = time.Now()\n\n\tvar pool chunkenc.Pool\n\tif m.Thanos.Downsample.Resolution == 0 {\n\t\tpool = chunkenc.NewPool()\n\t} else {\n\t\tpool = downsample.NewPool()\n\t}\n\n\tb, err := tsdb.OpenBlock(logutil.GoKitLogToSlog(logger), bdir, pool, nil)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"open block %s\", m.ULID)\n\t}\n\tdefer runutil.CloseWithLogOnErr(log.With(logger, \"outcome\", \"potential left mmap file handlers left\"), b, \"tsdb reader\")\n\n\tid, err := downsample.Downsample(ctx, logger, m, b, dir, resolution)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"downsample block %s to window %d\", m.ULID, resolution)\n\t}\n\tresdir := filepath.Join(dir, id.String())\n\n\tdownsampleDuration := time.Since(begin)\n\tlevel.Info(logger).Log(\"msg\", \"downsampled block\",\n\t\t\"from\", m.ULID, \"to\", id, \"duration\", downsampleDuration, \"duration_ms\", downsampleDuration.Milliseconds())\n\tmetrics.downsampleDuration.WithLabelValues(m.Thanos.ResolutionString()).Observe(downsampleDuration.Seconds())\n\n\tstats, err := block.GatherIndexHealthStats(ctx, logger, filepath.Join(resdir, block.IndexFilename), m.MinTime, m.MaxTime)\n\tif err == nil {\n\t\terr = stats.AnyErr()\n\t}","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/downsample.go#L363-L399","documentation":"processDownsampling wraps tsdb.OpenBlock failures as errors.Wrapf(err, \"open block %s\", m.ULID). The downloaded block directory cannot be opened as a TSDB block — typically missing/corrupt index, chunks, or meta.json files on local disk.","triggerScenarios":"tsdb.OpenBlock(bdir, pool, nil) fails because index file is unreadable/corrupt, chunk files are missing, meta.json is invalid, or the block directory was deleted mid-operation.","commonSituations":"Incomplete download that passed earlier checks but is missing chunk segments; disk corruption or cleanup daemon removing files from --data-dir; running out of file descriptors; checksum-identical but truncated files after a crash.","solutions":["Clear the block's directory under --data-dir and let the next cycle re-download it (local cache is safe to delete).","Check disk health and that no cleaner process removes files from --data-dir while downsampling runs.","Raise the process file-descriptor limit (ulimit -n) if errors indicate too many open files.","If the source block in the bucket is itself broken, remove it after verification so retries stop."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// validate local copy before opening\nfor _, f := range []string{\"meta.json\", \"index\"} {\n    if _, err := os.Stat(filepath.Join(bdir, f)); err != nil {\n        os.RemoveAll(bdir) // force re-download\n    }\n}","typeGuard":null,"tryCatchPattern":"b, err := tsdb.OpenBlock(logger, bdir, pool, nil)\nif err != nil {\n    os.RemoveAll(bdir) // clear local cache and retry next cycle\n    return fmt.Errorf(\"open block %s: %w\", m.ULID, err)\n}","preventionTips":["Treat --data-dir as an always-deletable cache; automate cleanup of stale block dirs.","Raise RLIMIT_NOFILE for the downsampler process.","Monitor disk health and avoid unclean shutdowns of nodes running downsamplers."],"tags":["tsdb","filesystem","block"],"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"}