{"record":{"id":"db80f656e4f30035","repo":"thanos-io/thanos","slug":"could-not-group-metadata-for-retention","errorCode":null,"errorMessage":"could not group metadata for retention","messagePattern":"could not group metadata for retention","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/compact.go","lineNumber":675,"sourceCode":"\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn errors.Wrapf(err, \"could not sync metas\")\n\t\t\t\t\t}\n\n\t\t\t\t\tmetas := sy.Metas()\n\t\t\t\t\tgroups, 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 compaction\")\n\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})","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/compact.go#L657-L693","documentation":"The same grouper.Groups(metas) call is re-run for the retention calculator; a failure here is wrapped as 'could not group metadata for retention'. Like the compaction grouping error, it indicates incompatible or duplicate blocks within a group (ErrGroupPermission / ErrGroupNotFound).","triggerScenarios":"grouper.Groups(metas) fails while building groups for retention calculation — duplicate blocks with the same external labels/resolution, or blocks referencing unknown resolution values.","commonSituations":"Duplicate blocks from concurrent compactors, backfilled blocks with clashing labels, or meta.json files with unexpected 'resolution' values (e.g. hand-edited metadata).","solutions":["Run 'thanos tools bucket verify' and 'repair --mark-logical-deleted' to deduplicate overlapping blocks.","Validate meta.json resolution values in the bucket are one of 0/5m/1h.","Guarantee a single compactor instance per bucket.","Fix external_labels on the Prometheus side so groups are unambiguous."],"exampleFix":"// before\n// overlapping blocks fail retention grouping\n// after\nthanos tools bucket verify --objstore.bucket=thanos\nthanos tools bucket repair --objstore.bucket=thanos --mark-logical-deleted","handlingStrategy":"validation","validationCode":"// Ensure resolutions in metadata are valid before grouping\nfor _, m := range metas {\n    switch m.Thanos.Resolution {\n    case 0, 5*time.Minute, time.Hour:\n    default:\n        log.Printf(\"invalid resolution %d in block %s\", m.Thanos.Resolution, m.ULID)\n    }\n}","typeGuard":null,"tryCatchPattern":"retGroups, err := grouper.Groups(metas)\nif err != nil {\n    log.Errorf(\"could not group metadata for retention: %v\", err)\n    alertDuplicateBlocks(err) // verify/repair bucket\n    return nil\n}","preventionTips":["Deduplicate overlapping blocks (bucket verify + repair).","Never hand-edit meta.json resolution fields.","Single compactor per bucket to avoid duplicates.","Validate backfilled blocks' labels before upload."],"tags":["thanos","retention","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"}