Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster health returns 500 when wait_for_active_shards is set to 'all' #31151

Closed
javanna opened this issue Jun 6, 2018 · 2 comments · Fixed by #31265
Closed

Cluster health returns 500 when wait_for_active_shards is set to 'all' #31151

javanna opened this issue Jun 6, 2018 · 2 comments · Fixed by #31265
Labels
>bug :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes)

Comments

@javanna
Copy link
Member

javanna commented Jun 6, 2018

Steps to reproduce (6.2, 6.x and master):

  1. create an index
curl -XPUT localhost:9200/index
  1. call cluster health with wait_for_active_shards set to all
curl 'localhost:9200/_cluster/health?wait_for_active_shards=all&pretty'

An IllegalStateException is returned as part of the response, the status code is 500:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_state_exception",
        "reason" : "not enough information to resolve to shard count"
      }
    ],
    "type" : "illegal_state_exception",
    "reason" : "not enough information to resolve to shard count"
  },
  "status" : 500
}

The error comes from https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/support/ActiveShardCount.java#L131 , reading from its javadocs "This method should only be invoked with ActiveShardCount objects created from from(int), or NONE or ONE". We are calling it though with ALL .

@javanna javanna added >bug :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) labels Jun 6, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this issue Jun 12, 2018
Today, if GET /_cluster/health?wait_for_active_shards=all does not immediately
succeed then it throws an exception due to an erroneous and unnecessary call to
ActiveShardCount#enoughShardsActive(). This commit fixes this logic.

Fixes elastic#31151
@DaveCTurner
Copy link
Contributor

Good catch. Looks like this goes all the way back to when this code was introduced in 5.0.0. I opened #31265.

DaveCTurner added a commit that referenced this issue Jun 13, 2018
Today, if GET /_cluster/health?wait_for_active_shards=all does not immediately
succeed then it throws an exception due to an erroneous and unnecessary call to
ActiveShardCount#enoughShardsActive(). This commit fixes this logic.

Fixes #31151
DaveCTurner added a commit that referenced this issue Jun 13, 2018
Today, if GET /_cluster/health?wait_for_active_shards=all does not immediately
succeed then it throws an exception due to an erroneous and unnecessary call to
ActiveShardCount#enoughShardsActive(). This commit fixes this logic.

Fixes #31151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants