{"record":{"id":"e249f951be0e8a93","repo":"thanos-io/thanos","slug":"could-not-group-metadata-into-downsample-groups","errorCode":null,"errorMessage":"could not group metadata into downsample groups","messagePattern":"could not group metadata into downsample groups","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/compact.go","lineNumber":685,"sourceCode":"\t\t\t\t\t}\n\n\t\t\t\t\tif err = ps.ProgressCalculate(ctx, groups); err != nil {\n\t\t\t\t\t\treturn errors.Wrapf(err, \"could not calculate compaction progress\")\n\t\t\t\t\t}\n\n\t\t\t\t\tretGroups, err := grouper.Groups(metas)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn errors.Wrapf(err, \"could not group metadata for retention\")\n\t\t\t\t\t}\n\n\t\t\t\t\tif err = rs.ProgressCalculate(ctx, retGroups); err != nil {\n\t\t\t\t\t\treturn errors.Wrapf(err, \"could not calculate retention progress\")\n\t\t\t\t\t}\n\n\t\t\t\t\tif !conf.disableDownsampling {\n\t\t\t\t\t\tgroups, err = grouper.Groups(metas)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn errors.Wrapf(err, \"could not group metadata into downsample groups\")\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif err := ds.ProgressCalculate(ctx, groups); err != nil {\n\t\t\t\t\t\t\treturn errors.Wrapf(err, \"could not calculate downsampling progress\")\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn nil\n\t\t\t\t})\n\t\t\t}, func(err error) {\n\t\t\t\tcancel()\n\t\t\t})\n\t\t}\n\t}\n\n\tlevel.Info(logger).Log(\"msg\", \"starting compact node\")\n\tstatusProber.Ready()\n\treturn nil\n}","sourceCodeStart":667,"sourceCodeEnd":703,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/compact.go#L667-L703","documentation":"When downsampling is enabled, grouper.Groups(metas) is invoked once more to build downsample groups; failure yields 'could not group metadata into downsample groups'. Same root causes as the other grouping errors: duplicate or incompatible blocks within a group (ErrGroupPermission / ErrGroupNotFound).","triggerScenarios":"grouper.Groups(metas) fails in the !conf.disableDownsampling branch of the progress loop — duplicate blocks sharing labels/resolution, or invalid resolution values in meta.json.","commonSituations":"Duplicate blocks produced by concurrent compactors, or backfilled/uploaded historical blocks with clashing external labels.","solutions":["Run 'thanos tools bucket verify' to find duplicates; repair with 'thanos tools bucket repair --mark-logical-deleted'.","Ensure a single compactor per bucket.","Fix Prometheus external_labels to make groups unique.","If downsampling metrics are not needed, run with --disable-downsampling to skip this path (compaction still groups once)."],"exampleFix":"// before\nthanos compact --objstore.bucket=thanos --data-dir=/var/thanos/compact\n// after\nthanos compact --objstore.bucket=thanos --data-dir=/var/thanos/compact --disable-downsampling\n# (only as mitigation; fix duplicate blocks first)","handlingStrategy":"validation","validationCode":"seen := map[string]struct{}{}\nfor _, m := range metas {\n    key := m.Thanos.Labels.String()\n    if _, dup := seen[key]; dup {\n        log.Printf(\"duplicate downsample group candidate: %s\", key)\n    }\n    seen[key] = struct{}{}\n}","typeGuard":null,"tryCatchPattern":"groups, err := grouper.Groups(metas)\nif err != nil {\n    if errors.Is(err, base.ErrGroupPermission) {\n        alertDuplicateBlocks(err)\n    }\n    return errors.Wrapf(err, \"could not group metadata into downsample groups\")\n}","preventionTips":["One compactor per bucket.","Run bucket verify/repair on duplicate-block alerts.","Use --disable-downsampling only as deliberate mitigation, not default.","Keep external labels unique per Prometheus."],"tags":["thanos","downsampling","grouping"],"backgroundTag":"duplicate-blocks-detected","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"}