Setting total_shards_per_node to zero

How does Elasticsearch handleindex.routing.allocation.total_shards_per_node getting set to 0 ? Setting it to 0 is obviously something that doesn't make sense to do, but Elasticsearch allows it to be done, so what if it is?

In my testing it seems like maybe the setting is ignored. If I set it for an index it's health remains green. If I remove a node one of the index's shards is on, the shard is recreated on another node.

That's correct, 0 (and -1) mean the limit is disabled:

-1 is the default value, used as a sentinel to mean "not set" -- this is a common pattern for many other settings regardless of whether 0 is a sensible value or not. In principle we could reject 0 here as well as numbers less than -1, but this would be a breaking change and we'd have to deprecate it first and maintain backwards compatibility with older nodes during a rolling upgrade and so on, so it would take quite some effort for IMO very little practical gain.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.