Skip to content

Commit f41a6ed

Browse files
Clarify unassigned.reason docs (#81017) (#81120)
Today we indicate that the `unassigned.reason` field in various APIs indicates the reason why a shard is unassigned. This isn't really true, it tells you some information about the event that caused the shard to _become_ unassigned (or which most recently changed its routing table entry while remaining unassigned) but tells you almost nothing about why the shard _is now_ unassigned and how to fix it. That's what the allocation explain API is for. This commit clarifies this point in the docs. Closes #80892 Co-authored-by: James Rodewig <james.rodewig@elastic.co> Co-authored-by: James Rodewig <james.rodewig@elastic.co>
1 parent ca8cc1f commit f41a6ed

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

docs/reference/cat/shards.asciidoc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ Time at which the shard became unassigned in
249249
Time (UTC)].
250250

251251
`unassigned.details`, `ud`::
252-
Details about why the shard became unassigned.
252+
Details about why the shard became unassigned. This does not explain why the
253+
shard is currently unassigned. To understand why a shard is not assigned, use
254+
the <<cluster-allocation-explain>> API.
253255

254256
`unassigned.for`, `uf`::
255257
Time at which the shard was requested to be unassigned in
@@ -258,16 +260,24 @@ Time (UTC)].
258260

259261
[[reason-unassigned]]
260262
`unassigned.reason`, `ur`::
261-
Reason the shard is unassigned. Returned values are:
263+
Indicates the reason for the last change to the state of this unassigned shard.
264+
This does not explain why the shard is currently unassigned. To understand why
265+
a shard is not assigned, use the <<cluster-allocation-explain>> API. Returned
266+
values include:
262267
+
263268
* `ALLOCATION_FAILED`: Unassigned as a result of a failed allocation of the shard.
264269
* `CLUSTER_RECOVERED`: Unassigned as a result of a full cluster recovery.
265270
* `DANGLING_INDEX_IMPORTED`: Unassigned as a result of importing a dangling index.
266271
* `EXISTING_INDEX_RESTORED`: Unassigned as a result of restoring into a closed index.
272+
* `FORCED_EMPTY_PRIMARY`: The shard's allocation was last modified by forcing an empty primary using the <<cluster-reroute>> API.
273+
* `INDEX_CLOSED`: Unassigned because the index was closed.
267274
* `INDEX_CREATED`: Unassigned as a result of an API creation of an index.
268275
* `INDEX_REOPENED`: Unassigned as a result of opening a closed index.
276+
* `MANUAL_ALLOCATION`: The shard's allocation was last modified by the <<cluster-reroute>> API.
269277
* `NEW_INDEX_RESTORED`: Unassigned as a result of restoring into a new index.
270278
* `NODE_LEFT`: Unassigned as a result of the node hosting it leaving the cluster.
279+
* `NODE_RESTARTING`: Similar to `NODE_LEFT`, except that the node was registered as restarting using the <<node-lifecycle-api,Node shutdown API>>.
280+
* `PRIMARY_FAILED`: The shard was initializing as a replica, but the primary shard failed before the initialization completed.
271281
* `REALLOCATED_REPLICA`: A better replica location is identified and causes the existing replica allocation to be cancelled.
272282
* `REINITIALIZED`: When a shard moves from started back to initializing.
273283
* `REPLICA_ADDED`: Unassigned as a result of explicit addition of a replica.

docs/reference/how-to/fix-common-cluster-issues.asciidoc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,11 @@ GET _cat/shards?v=true&h=index,shard,prirep,state,node,unassigned.reason&s=state
420420
----
421421

422422
Unassigned shards have a `state` of `UNASSIGNED`. The `prirep` value is `p` for
423-
primary shards and `r` for replicas. The `unassigned.reason` describes why the
424-
shard remains unassigned.
423+
primary shards and `r` for replicas.
425424

426-
To get a more in-depth explanation of an unassigned shard's allocation status,
427-
use the <<cluster-allocation-explain,cluster allocation explanation API>>. You
428-
can often use details in the response to resolve the issue.
425+
To understand why an unassigned shard is not being assigned and what action
426+
you must take to allow {es} to assign it, use the
427+
<<cluster-allocation-explain,cluster allocation explanation API>>.
429428

430429
[source,console]
431430
----

server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected Table getTableWithHeader(final RestRequest request) {
118118

119119
table.addCell("sync_id", "alias:sync_id;default:false;desc:sync id");
120120

121-
table.addCell("unassigned.reason", "alias:ur;default:false;desc:reason shard is unassigned");
121+
table.addCell("unassigned.reason", "alias:ur;default:false;desc:reason shard became unassigned");
122122
table.addCell("unassigned.at", "alias:ua;default:false;desc:time shard became unassigned (UTC)");
123123
table.addCell("unassigned.for", "alias:uf;default:false;text-align:right;desc:time has been unassigned");
124124
table.addCell("unassigned.details", "alias:ud;default:false;desc:additional details as to why the shard became unassigned");

0 commit comments

Comments
 (0)