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

Partial shard failures rendered as non-structured exceptions #11017

Closed
clintongormley opened this issue May 6, 2015 · 0 comments · Fixed by #11155
Closed

Partial shard failures rendered as non-structured exceptions #11017

clintongormley opened this issue May 6, 2015 · 0 comments · Fixed by #11155
Assignees
Labels
:Core/Infra/REST API REST infrastructure and utilities

Comments

@clintongormley
Copy link

DELETE * 

PUT test/test/1
{
  "foz": "bar"
}

GET _search?sort=foo

Rendered as a structured exception:

{
   "error": {
      "root_cause": [
         {
            "type": "search_parse_exception",
            "reason": "No mapping found for [foo] in order to sort on"
         }
      ],
      "type": "search_phase_execution_exception",
      "reason": "all shards failed",
      "phase": "query",
      "grouped": true,
      "failed_shards": [
         {
            "shard": 0,
            "index": "test",
            "node": "v04p8T35S1ySNdsF9GTl7w",
            "reason": {
               "type": "search_parse_exception",
               "reason": "Failed to parse source [{\"sort\":[{\"foo\":{}}]}]",
               "caused_by": {
                  "type": "search_parse_exception",
                  "reason": "No mapping found for [foo] in order to sort on"
               }
            }
         }
      ]
   },
   "status": 400
}

However, if one shard succeeds, then exceptions are no longer structured:

PUT test2/test/1
{
  "foo": "bar"
}

GET _search?sort=foo

Renders as:

{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 10,
      "successful": 5,
      "failed": 5,
      "failures": [
         {
            "index": "test",
            "shard": 0,
            "status": 400,
            "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\":[{\"foo\":{}}]}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
         },
         {
            "index": "test",
            "shard": 1,
            "status": 400,
            "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\":[{\"foo\":{}}]}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
         },
         {
            "index": "test",
            "shard": 2,
            "status": 400,
            "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\":[{\"foo\":{}}]}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
         },
         {
            "index": "test",
            "shard": 3,
            "status": 400,
            "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\":[{\"foo\":{}}]}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
         },
         {
            "index": "test",
            "shard": 4,
            "status": 400,
            "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\":[{\"foo\":{}}]}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
         }
      ]
   },
   "hits": {
      "total": 1,
      "max_score": null,
      "hits": [
         {
            "_index": "test2",
            "_type": "test",
            "_id": "1",
            "_score": null,
            "_source": {
               "foo": "bar"
            },
            "sort": [
               "bar"
            ]
         }
      ]
   }
}

Similarly, errors in bulk APIs are not structured:

PUT test/test/_bulk
{"index": {"_id": 1 }}
{}
{"index": {"_id": 1 ,"_version": 2}}
{}

Returns:

{
   "took": 60,
   "errors": true,
   "items": [
      {
         "index": {
            "_index": "test",
            "_type": "test",
            "_id": "1",
            "_version": 1,
            "_shards": {
               "total": 2,
               "successful": 1,
               "failed": 0
            },
            "status": 201
         }
      },
      {
         "index": {
            "_index": "test",
            "_type": "test",
            "_id": "1",
            "status": 409,
            "error": "[test][3][test][1]: version conflict, current [1], provided [2]"
         }
      }
   ]
}

Curiously, _msearch doesn't return the reason if all shards failed:

GET _msearch
{"index": "test"}
{"sort": "foo"}
{"index": "_all"}
{"sort": "foo"}

Returns:

{
   "responses": [
      {
         "error": "SearchPhaseExecutionException[all shards failed]"
      },
      {
         "took": 6,
         "timed_out": false,
         "_shards": {
            "total": 10,
            "successful": 5,
            "failed": 5,
            "failures": [
               {
                  "index": "test",
                  "shard": 0,
                  "status": 400,
                  "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\": \"foo\"}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
               },
               {
                  "index": "test",
                  "shard": 1,
                  "status": 400,
                  "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\": \"foo\"}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
               },
               {
                  "index": "test",
                  "shard": 2,
                  "status": 400,
                  "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\": \"foo\"}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
               },
               {
                  "index": "test",
                  "shard": 3,
                  "status": 400,
                  "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\": \"foo\"}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
               },
               {
                  "index": "test",
                  "shard": 4,
                  "status": 400,
                  "reason": "RemoteTransportException[[Frigga][inet[/192.168.2.183:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[Failed to parse source [{\"sort\": \"foo\"}]]; nested: SearchParseException[No mapping found for [foo] in order to sort on]; "
               }
            ]
         },
         "hits": {
            "total": 1,
            "max_score": null,
            "hits": [
               {
                  "_index": "test2",
                  "_type": "test",
                  "_id": "1",
                  "_score": null,
                  "_source": {
                     "foo": "bar"
                  },
                  "sort": [
                     "bar"
                  ]
               }
            ]
         }
      }
   ]
}
@clintongormley clintongormley added the :Core/Infra/REST API REST infrastructure and utilities label May 6, 2015
s1monw added a commit to s1monw/elasticsearch that referenced this issue May 13, 2015
ShardOperationFailureException implementations alread provide structured
exception support but it's not yet exposed on the interface. This change
allows nice rendering of structured REST exceptions also if searches fail on
only a subset of the shards etc.

Closes elastic#11017
s1monw added a commit to s1monw/elasticsearch that referenced this issue May 15, 2015
ShardOperationFailureException implementations alread provide structured
exception support but it's not yet exposed on the interface. This change
allows nice rendering of structured REST exceptions also if searches fail on
only a subset of the shards etc.

Closes elastic#11017
s1monw added a commit to s1monw/elasticsearch that referenced this issue May 18, 2015
ShardOperationFailureException implementations alread provide structured
exception support but it's not yet exposed on the interface. This change
allows nice rendering of structured REST exceptions also if searches fail on
only a subset of the shards etc.

Closes elastic#11017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/REST API REST infrastructure and utilities
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants