{"record":{"id":"583e9422224cd339","repo":"thanos-io/thanos","slug":"downsample-block-s-to-window-d","errorCode":null,"errorMessage":"downsample block %s to window %d","messagePattern":"downsample block (.+?) to window (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/downsample.go","lineNumber":387,"sourceCode":"\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}\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 {","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/downsample.go#L369-L405","documentation":"Wraps downsample.Downsample failures as errors.Wrapf(err, \"downsample block %s to window %d\", m.ULID, resolution). The actual aggregation of raw series into the coarser-resolution block failed — query/iterator errors, aggregation panics, or failure writing the resulting block.","triggerScenarios":"downsample.Downsample(ctx, logger, m, b, dir, resolution) returns error: corrupt chunk data encountered while iterating, unsupported chunk encodings, out-of-memory while aggregating, or inability to create/write the result block in dir.","commonSituations":"Source blocks containing corrupted chunks written by older versions; OOM-killed downsampler on very large blocks; disk full in --data-dir when writing the downsampled output.","solutions":["Inspect the inner error; if it is data corruption in the source block, delete/regenerate that block.","Give the downsampler more memory or reduce --downsample-concurrency to limit concurrent large aggregations.","Free disk space in --data-dir or point it at a larger volume.","Upgrade Thanos — several historical downsample bugs (chunk handling) were fixed in later releases."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := processDownsampling(...); err != nil {\n    var rerr *compact.RetryError\n    if errors.As(err, &rerr) { /* retry later */ }\n    metrics.downsampleFailures.WithLabelValues(res).Inc()\n    return errors.Wrapf(err, \"downsample block %s to window %d\", id, resolution)\n}","preventionTips":["Right-size memory requests/limits for the downsampler relative to largest block size.","Cap --downsample-concurrency so concurrent aggregations don't exhaust RAM/disk.","Keep Thanos updated; downsample chunk-handling bugs are fixed regularly."],"tags":["downsampling","aggregation","memory"],"backgroundTag":"database-query-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"}