Hey,
I've been having a shard-assignment issue with my Elastic 5.4.0 ever since I started using it, a problem that also happened in the previous version we used, 1.7.
We have 6 nodes in the cluster, 3 of them are dedicated Master Nodes and 3 are Data Nodes.
The specs for the nodes are -
Master Node - 14GB RAM (7GB configured for JVM), 4 CPU
Data Node - 14GB RAM (7GB configured for JVM), 4 CPU, 2 disks of 50 GB each (So 6 disks total and 300GB storage for the whole cluster)
Each index we create in the cluster is created with 3 primary shards, and 1 replica shard,
and the allocation configuration set the total_shards_per_node to be 2.
So ideally, for each index, each node should 1 primary shard and 1 replica shard, in a "circular" assignment like this -
Node 1 - P1, R3
Node 2 - P2, R1
Node 3 - P3, R2
All indices should be assigned like this, and cluster should end up in a fully green state.
The problem I see is that Elastic doesn't always assign the shards in the circular way I described above, but sometimes it assigns them in a way that doesn't leave it with any node for the last replica. The assignment it sometimes does is -
Node 1 - P1, __
Node 2 - P2, R3
Node 3 - P3, R2
Thus, leaving it with no node left for replica R1, since it can't be on the same node with P1 of course (Node 1), and each node can't have more than 2 shards on it.
I can't understand why it only sometimes happen, and why Elastic fails to figure out the circular allocation route that will allow him to set all the replica nodes where they should be.
So we have a yellow cluster due to this unsuccessful assignment of shards.
I'm attaching here all configuration and API calls that might be relevant to debug the issue -
Elastic version (from the / endpoint)
Summary
"version": {
"number": "5.4.0",
"build_hash": "780f8c4",
"build_date": "2017-04-28T17:43:27.229Z",
"build_snapshot": false,
"lucene_version": "6.5.0"
}
Relevant problematic index settings
Summary
{
"index-name": {
"settings": {
"index": {
"routing": {
"allocation": {
"total_shards_per_node": "2"
}
},
"mapping": {
"total_fields": {
"limit": "2000"
}
},
"number_of_shards": "3",
"unassigned": {
"node_left": {
"delayed_timeout": "15m"
}
},
"number_of_replicas": "0"
}
}
}
}
The unassigned shard status from _cat/shards API call
index-name 2 r UNASSIGNED REPLICA_ADDED
The result of the /_cluster/allocation/explain API for the problematic index and the problematic replica shard that can't be assigned
Summary
{
"index": "index-name",
"shard": 2,
"primary": false,
"current_state": "unassigned",
"unassigned_info": {
"reason": "REPLICA_ADDED",
"at": "2018-03-12T16:04:37.589Z",
"last_allocation_status": "no_attempt"
},
"can_allocate": "no",
"allocate_explanation": "cannot allocate because allocation is not permitted to any of the nodes",
"node_allocation_decisions": [
{
"node_id": "D_0f7PlUQh2xCQVJ04mXkw",
"node_name": "Node3",
"transport_address": "IP",
"node_decision": "no",
"deciders": [
{
"decider": "shards_limit",
"decision": "NO",
"explanation": "too many shards [2] allocated to this node for index [index-name], index setting [index.routing.allocation.total_shards_per_node=2]"
}
]
},
{
"node_id": "pzVpw4vtQg-ecAGoYkQzqw",
"node_name": "Node1",
"transport_address": "IP1",
"node_decision": "no",
"store": {
"matching_size_in_bytes": 130
},
"deciders": [
{
"decider": "same_shard",
"decision": "NO",
"explanation": "the shard cannot be allocated to the same node on which a copy of the shard already exists [[index-name][2], node[Node1], [P], s[STARTED], a[id=N9RA7hJ5SquJK1y_vgKo0Q]]"
}
]
},
{
"node_id": "zJBuKkKlTbWZCofdn1NCvg",
"node_name": "Node2",
"transport_address": "IP",
"node_decision": "no",
"deciders": [
{
"decider": "shards_limit",
"decision": "NO",
"explanation": "too many shards [2] allocated to this node for index [index-name], index setting [index.routing.allocation.total_shards_per_node=2]"
}
]
}
]
}
I'll add that if I remove the replica and add it a few times, eventually Elastic will have a successful assignment (of the circular case).
Let me know if any additional API calls are needed and I'll gladly add those.
Thanks in advance for any help!