{"record":{"id":"1d3194d0e10dad98","repo":"thanos-io/thanos","slug":"read-meta","errorCode":null,"errorMessage":"read meta","messagePattern":"read meta","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/downsample.go","lineNumber":406,"sourceCode":"\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}\n\tif err != nil && !acceptMalformedIndex {\n\t\treturn errors.Wrap(err, \"output block index not valid\")\n\t}\n\n\tmeta, err := metadata.ReadFromDir(resdir)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"read meta\")\n\t}\n\n\tif stats.ChunkMaxSize > 0 {\n\t\tmeta.Thanos.IndexStats.ChunkMaxSize = stats.ChunkMaxSize\n\t}\n\tif stats.SeriesMaxSize > 0 {\n\t\tmeta.Thanos.IndexStats.SeriesMaxSize = stats.SeriesMaxSize\n\t}\n\tif err := meta.WriteToDir(logger, resdir); err != nil {\n\t\treturn errors.Wrap(err, \"write meta\")\n\t}\n\n\tbegin = time.Now()\n\n\terr = block.Upload(ctx, logger, bkt, resdir, hashFunc, objstore.WithUploadConcurrency(blockFilesConcurrency))\n\tif err != nil {\n\t\treturn compact.NewRetryError(errors.Wrapf(err, \"upload downsampled block %s\", id))\n\t}","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/downsample.go#L388-L424","documentation":"processDownsampling wraps metadata.ReadFromDir(resdir) failures as \"read meta\". The meta.json of the freshly downsampled output block (resdir) cannot be read or parsed. This normally means the file is missing or not valid JSON/meta schema.","triggerScenarios":"metadata.ReadFromDir on the result directory fails because meta.json was not written by the downsample step (e.g. process killed mid-write), JSON is malformed, or the directory was removed concurrently.","commonSituations":"Disk full during block write so meta.json is truncated; operator/scripts deleting files in --data-dir while downsampling runs; OOM kill between block creation and meta write.","solutions":["Delete the partial output directory for that block under --data-dir and let the next cycle regenerate it.","Check free disk space and dmesg for OOM/IO errors during the downsampling run.","Ensure nothing else (cron cleanup, shared volume users) mutates --data-dir while thanos downsample runs."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"metaPath := filepath.Join(resdir, \"meta.json\")\nif _, err := os.Stat(metaPath); err != nil {\n    os.RemoveAll(resdir) // incomplete output; force regeneration\n}","typeGuard":null,"tryCatchPattern":"meta, err := metadata.ReadFromDir(resdir)\nif err != nil {\n    os.RemoveAll(resdir)\n    return errors.Wrap(err, \"read meta\")\n}","preventionTips":["Ensure adequate free space in --data-dir so meta.json writes are never truncated.","Do not run cleanup jobs against the downsampler's data dir concurrently.","Check for OOM kills (dmesg) if \"read meta\" errors cluster at specific blocks."],"tags":["metadata","json","block"],"backgroundTag":"file-read-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"}