{"record":{"id":"0781b3f34a9f3273","repo":"thanos-io/thanos","slug":"read-meta-of-v","errorCode":null,"errorMessage":"read meta of %v","messagePattern":"read meta of (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/tools_bucket.go","lineNumber":1255,"sourceCode":"\t\tif err := os.MkdirAll(tbc.tmpDir, os.ModePerm); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tg.Add(func() error {\n\t\t\tchunkPool := chunkenc.NewPool()\n\t\t\tchangeLog := compactv2.NewChangeLog(io.Discard)\n\t\t\tstubCounter := promauto.With(nil).NewCounter(prometheus.CounterOpts{})\n\t\t\tfor _, id := range ids {\n\t\t\t\t// Delete series from block & modify.\n\t\t\t\tlevel.Info(logger).Log(\"msg\", \"downloading block\", \"source\", id)\n\t\t\t\tif err := block.Download(ctx, logger, insBkt, id, filepath.Join(tbc.tmpDir, id.String())); err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"download %v\", id)\n\t\t\t\t}\n\n\t\t\t\tmeta, err := metadata.ReadFromDir(filepath.Join(tbc.tmpDir, id.String()))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"read meta of %v\", id)\n\t\t\t\t}\n\t\t\t\tb, err := tsdb.OpenBlock(logutil.GoKitLogToSlog(logger), filepath.Join(tbc.tmpDir, id.String()), chunkPool, nil)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"open block %v\", id)\n\t\t\t\t}\n\n\t\t\t\tp := compactv2.NewProgressLogger(logger, int(b.Meta().Stats.NumSeries))\n\t\t\t\tnewID := ulid.MustNew(ulid.Now(), rand.Reader)\n\t\t\t\tmeta.ULID = newID\n\t\t\t\tmeta.Thanos.Rewrites = append(meta.Thanos.Rewrites, metadata.Rewrite{\n\t\t\t\t\tSources:          meta.Compaction.Sources,\n\t\t\t\t\tDeletionsApplied: deletions,\n\t\t\t\t\tRelabelsApplied:  relabels,\n\t\t\t\t})\n\t\t\t\tmeta.Compaction.Sources = []ulid.ULID{newID}\n\t\t\t\tmeta.Thanos.Source = metadata.BucketRewriteSource\n\n\t\t\t\tif err := os.MkdirAll(filepath.Join(tbc.tmpDir, newID.String()), os.ModePerm); err != nil {","sourceCodeStart":1237,"sourceCodeEnd":1273,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/tools_bucket.go#L1237-L1273","documentation":"Wraps metadata.ReadFromDir failing after download, i.e. the downloaded block directory has no valid meta.json. ReadFromDir parses the JSON meta file; failures come from a missing meta.json or unparseable/corrupt JSON content in tmpDir.","triggerScenarios":"Download only partially completed (meta.json never fetched); meta.json corrupted in the object store; another rewrite run left a stale/partial block in the same tmpDir; disk filled and truncated the file.","commonSituations":"Shared tmpDir collisions when running two rewrite commands with the same temp dir; interrupted previous run leaving partial download; object store object corrupted; out-of-disk conditions.","solutions":["Delete the stale temp dir (or let the command's os.RemoveAll run fresh) and retry the rewrite.","Check meta.json exists and is valid in the object store: `thanos tools bucket inspect` or download meta.json manually.","Free disk space / verify tmpDir is on a writable, non-full volume, then retry."],"exampleFix":"// before (stale tmp dir)\nTMPDIR=/data/thanos-rewrite\n// after (fresh unique tmp dir per run)\nthanos tools bucket rewrite --tmp.dir=/data/thanos-rewrite-$(date +%s) ...","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(filepath.Join(blockDir, \"meta.json\")); err != nil {\n    return fmt.Errorf(\"meta.json missing in %s\", blockDir)\n}","typeGuard":null,"tryCatchPattern":"meta, err := metadata.ReadFromDir(dir)\nif err != nil {\n    os.RemoveAll(dir) // clean stale partial download\n    return errors.Wrapf(err, \"read meta of %v\", id)\n}","preventionTips":["Use a unique tmpDir per run to avoid stale collisions","Ensure adequate free disk space","Verify meta.json exists in the object store before rewriting"],"tags":["thanos","metadata","file-not-found","corruption"],"backgroundTag":"file-not-found","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"}