{"record":{"id":"cd40ff76df148a67","repo":"thanos-io/thanos","slug":"output-block-index-not-valid","errorCode":null,"errorMessage":"output block index not valid","messagePattern":"output block index not valid","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/downsample.go","lineNumber":401,"sourceCode":"\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}\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()","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/downsample.go#L383-L419","documentation":"After downsample.Downsample produces a new block, processDownsampling runs block.GatherIndexHealthStats on the output index and wraps failures as \"output block index not valid\" unless acceptMalformedIndex is set. The newly generated downsampled block's index fails health verification (e.g. stats.AnyErr() reports issues like oversized or inconsistent chunks).","triggerScenarios":"GatherIndexHealthStats returns an error or stats.AnyErr() is non-nil, and --accept-malformed-index is false: downsampled index has postings/timestamps outside m.MinTime..m.MaxTime or other health-stat failures.","commonSituations":"Downsampling blocks that already contained marginal/corrupt data; historic Thanos downsampler bugs producing indexes with too-large chunks; verifying output against the parent block's time range when output legitimately differs.","solutions":["Re-run downsampling after removing the intermediate directory for that block in --data-dir to force a clean regeneration.","Upgrade Thanos: several downsampler index-quality bugs (chunk max size, resolution handling) were fixed over time.","Use --accept-malformed-index deliberately if the identified issue is known-benign for your setup.","Check the parent block's index health first; a bad input produces a bad output."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"stats, err := block.GatherIndexHealthStats(ctx, logger, filepath.Join(resdir, block.IndexFilename), m.MinTime, m.MaxTime)\nif err == nil { err = stats.AnyErr() }\nif err != nil {\n    os.RemoveAll(resdir) // discard bad output before upload\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always verify the parent block's index before downsampling; bad input yields bad output.","Run a recent Thanos version where output index health checks and downsampler fixes are current.","Gate uploads behind index health checks in any custom pipeline."],"tags":["index","validation","downsampling"],"backgroundTag":"schema-validation-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"}