{"record":{"id":"71d2ae181ebda00f","repo":"thanos-io/thanos","slug":"hashmod-algorithm-does-not-support-shuffle-shardin","errorCode":null,"errorMessage":"hashmod algorithm does not support shuffle sharding. Either use Ketama or remove shuffle sharding configuration","messagePattern":"hashmod algorithm does not support shuffle sharding\\. Either use Ketama or remove shuffle sharding configuration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/hashring.go","lineNumber":738,"sourceCode":"\t\t}\n\t\tm.tenantSets = append(m.tenantSets, t)\n\t}\n\tslices.SortFunc(m.nodes, func(a, b Endpoint) int {\n\t\treturn strings.Compare(a.Address, b.Address)\n\t})\n\treturn m, nil\n}\n\nfunc newHashring(algorithm HashringAlgorithm, endpoints []Endpoint, replicationFactor uint64, hashring string, tenants []string, shuffleShardingConfig ShuffleShardingConfig, reg prometheus.Registerer) (Hashring, error) {\n\n\tswitch algorithm {\n\tcase AlgorithmHashmod:\n\t\tringImpl, err := newSimpleHashring(endpoints)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif shuffleShardingConfig.ShardSize > 0 {\n\t\t\treturn nil, fmt.Errorf(\"hashmod algorithm does not support shuffle sharding. Either use Ketama or remove shuffle sharding configuration\")\n\t\t}\n\t\treturn ringImpl, nil\n\tcase AlgorithmKetama:\n\t\tringImpl, err := newKetamaHashring(endpoints, SectionsPerNode, replicationFactor)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif shuffleShardingConfig.ShardSize > 0 {\n\t\t\tif shuffleShardingConfig.ShardSize > len(endpoints) {\n\t\t\t\treturn nil, fmt.Errorf(\"shard size %d is larger than number of nodes in hashring %s (%d)\", shuffleShardingConfig.ShardSize, hashring, len(endpoints))\n\t\t\t}\n\t\t\treturn newShuffleShardHashring(ringImpl, shuffleShardingConfig, replicationFactor, reg, hashring)\n\t\t}\n\t\treturn ringImpl, nil\n\tdefault:\n\t\tl := log.NewNopLogger()\n\t\tlevel.Warn(l).Log(\"msg\", \"Unrecognizable hashring algorithm. Fall back to hashmod algorithm.\",\n\t\t\t\"hashring\", hashring,","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/hashring.go#L720-L756","documentation":"newHashringConfig (hashmod branch) rejects a configuration that combines the hashmod algorithm with shuffle sharding (shardSize > 0). Shuffle sharding is only implemented for the Ketama algorithm, so the combination is unsupported and construction fails immediately.","triggerScenarios":"Hashring config sets algorithm: hashmod together with shuffleSharding.shardSize > 0 when the hashring config is parsed/built.","commonSituations":"Operator switches algorithm back to hashmod after previously using shuffle sharding but forgets to remove the shardSize; copied config templates that include shardSize by default.","solutions":["Either remove the shuffleSharding.shardSize (set to 0/omit) from the hashring config","Or change the algorithm to Ketama, which supports shuffle sharding","Restart/redeploy receivers so all nodes load the corrected hashring config"],"exampleFix":"// before\nhashring: ring-0\nalgorithm: hashmod\nshuffleSharding:\n  shardSize: 3\n// after (option A)\nhashring: ring-0\nalgorithm: hashmod\n// or option B\nalgorithm: ketama","handlingStrategy":"validation","validationCode":"func validateHashringCfg(cfg HashringConfig) error {\n    if !strings.EqualFold(cfg.Algorithm, \"ketama\") && cfg.ShuffleSharding.ShardSize > 0 {\n        return errors.New(\"shuffle sharding requires ketama algorithm\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"ring, err := newHashringConfig(...)\nif err != nil {\n    return nil, fmt.Errorf(\"invalid hashring config: %w\", err)\n}","preventionTips":["Never set shardSize when algorithm is hashmod","Validate combined algorithm+shuffleSharding settings before deploy","Use config schema validation in CI"],"tags":["hashring","shuffle-sharding","config"],"backgroundTag":"conflicting-config-options","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"}