# Invalid response for \_forcemerge, \_cache/clear APIs when unassigned shards

**URL:** <https://discuss.elastic.co/t/invalid-response-for-forcemerge-cache-clear-apis-when-unassigned-shards/248901>\
**Category:** Elasticsearch\
**Created:** [September 17, 2020, 2:36am UTC](https://discuss.elastic.co/t/invalid-response-for-forcemerge-cache-clear-apis-when-unassigned-shards/248901 "2020-09-17T02:36:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![setiah](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@setiah](https://discuss.elastic.co/u/setiah)\
**Post date:** [September 17, 2020, 2:37am UTC](https://discuss.elastic.co/t/invalid-response-for-forcemerge-cache-clear-apis-when-unassigned-shards/248901/1 "2020-09-17T02:37:00Z")

</div>

Hi,

**Issue**  
When \_forcemerge is tried on an index or a group of indices that has some unassigned shards, the response returned does not indicate failures for unassigned shards. Even the `total`, `failed` and `successful` counts don't seem to tally.

This is true for index \_cache/clear and index \_stats API as well.

**Failure Logs**

It can be seen that, `successful + failed != total` here

```
➜ curl localhost:9200/_cat/shards
my_index 0 p UNASSIGNED
my_index 0 r UNASSIGNED

➜ curl -XPOST "localhost:9200/my_index/_forcemerge?pretty" -d'{}' -H 'Content-Type: application/json'
{
  "_shards" : {
    "total" : 2,
    "successful" : 0,
    "failed" : 0
  }
}

```

**Probable Cause**  
In the TransportBroadcastByNodeAction, if a shard that requires action is unassigned, it is added to the [unavailableShardExceptions list](https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java#L278) but at the time of collating responses, [this list is not added to the failedShards and other exceptions for reporting in response](https://github.com/elastic/elasticsearch/blob/ca11665c035378c1d1ead4a002233cefffd929db/server/src/main/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java#L148-L150)

Is this a bug?

Thanks!

---

<div class="post-metadata">

**Author:** ![setiah](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@setiah](https://discuss.elastic.co/u/setiah)\
**Post date:** [September 21, 2020, 11:58pm UTC](https://discuss.elastic.co/t/invalid-response-for-forcemerge-cache-clear-apis-when-unassigned-shards/248901/2 "2020-09-21T23:58:42Z")

</div>

Hi Guys,

Could someone look into this please?

Regards

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 19, 2020, 11:58pm UTC](https://discuss.elastic.co/t/invalid-response-for-forcemerge-cache-clear-apis-when-unassigned-shards/248901/3 "2020-10-19T23:58:44Z")

</div>

Closed on October 19, 2020, 11:58pm UTC

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