{"record":{"id":"a8db06c0380bfe36","repo":"thanos-io/thanos","slug":"min-horizontal-shards-should-be-greater-than-0-whe","errorCode":null,"errorMessage":"min horizontal shards should be greater than 0 when query split threshold is enabled","messagePattern":"min horizontal shards should be greater than 0 when query split threshold is enabled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/queryfrontend/config.go","lineNumber":309,"sourceCode":"\t\tif err := cfg.LabelsConfig.ResultsCacheConfig.Validate(querier.Config{}); err != nil {\n\t\t\treturn errors.Wrap(err, \"invalid ResultsCache config for labels tripperware\")\n\t\t}\n\t}\n\n\tif cfg.DefaultTimeRange == 0 {\n\t\treturn errors.New(\"labels.default-time-range cannot be set to 0\")\n\t}\n\n\tif cfg.DownstreamURL == \"\" {\n\t\treturn errors.New(\"downstream URL should be configured\")\n\t}\n\n\treturn nil\n}\n\nfunc (cfg *Config) validateDynamicSplitParams() error {\n\tif cfg.HorizontalShards <= 0 {\n\t\treturn errors.New(\"min horizontal shards should be greater than 0 when query split threshold is enabled\")\n\t}\n\n\tif cfg.MaxQuerySplitInterval <= 0 {\n\t\treturn errors.New(\"max query split interval should be greater than 0 when query split threshold is enabled\")\n\t}\n\n\tif cfg.MinQuerySplitInterval <= 0 {\n\t\treturn errors.New(\"min query split interval should be greater than 0 when query split threshold is enabled\")\n\t}\n\treturn nil\n}\n\nfunc (cfg *Config) isStaticSplitSet() bool {\n\treturn cfg.QueryRangeConfig.SplitQueriesByInterval != 0\n}\n\nfunc (cfg *Config) isDynamicSplitSet() bool {\n\treturn cfg.MinQuerySplitInterval > 0 ||","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/queryfrontend/config.go#L291-L327","documentation":"validateDynamicSplitParams enforces that all dynamic query-splitting settings are positive when the split-by-query-threshold feature is in use. HorizontalShards is the minimum number of horizontal shards, so a value <= 0 makes the shard math undefined; startup fails with this error.","triggerScenarios":"Validate -> validateDynamicSplitParams is called with cfg.HorizontalShards <= 0, i.e. query_split_threshold is enabled (or dynamic splitting active) but horizontal_shards was left at its zero value or set to a negative number.","commonSituations":"Operators enabling query_split_threshold but omitting horizontal_shards; configs where horizontal_shards was intended to mean 'unlimited' and set to 0; upgrade paths where new dynamic-split fields default to zero.","solutions":["Set query_frontend.horizontal_shards to a positive integer (e.g. 3)","If dynamic splitting is not desired, disable query_split_threshold so validateDynamicSplitParams semantics don't apply","Validate config before deploy with cortex's config validation"],"exampleFix":"// before\nquery_frontend:\n  query_split_threshold: 100000\n  # horizontal_shards not set\n// after\nquery_frontend:\n  query_split_threshold: 100000\n  horizontal_shards: 3","handlingStrategy":"validation","validationCode":"if cfg.HorizontalShards <= 0 {\n    return errors.New(\"horizontal_shards must be > 0 when query_split_threshold is enabled\")\n}","typeGuard":"func dynamicSplitReady(cfg Config) bool {\n    return cfg.HorizontalShards > 0 && cfg.MaxQuerySplitInterval > 0 && cfg.MinQuerySplitInterval > 0\n}","tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"horizontal shards\") {\n        log.Fatalf(\"set horizontal_shards > 0: %v\", err)\n    }\n}","preventionTips":["Set all dynamic-split fields (horizontal_shards, min/max_query_split_interval) together whenever query_split_threshold is enabled","Do not use 0 to mean 'disabled'; disable the feature flag itself instead","Add config linting that cross-checks query_split_threshold with its sibling fields"],"tags":["config","validation","query-frontend","sharding"],"backgroundTag":"invalid-config-value","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"}