Skip to content

Certain shard failure response no longer contains error property #54235

Closed
@tylersmalley

Description

@tylersmalley

This effects 7.7.0+

This is a pretty particular error to hit, so I am assuming the regression was not intentional. It appears that for an invalid scripted field, it is failing only one of the shards and skipping the rest which is resulting in a hits response instead of an error.

This change broke a test we had in Kibana, preventing the promotion of our nightly snapshot. Looking for guidance on if this is an accidental regression or we should update our checks accordingly.

Here is the minimum reproduction I could come up with:

cURL friendly commands

curl -XPUT "http://localhost:9200/test-1" -H 'Content-Type: application/json' -d'{ "settings": { "number_of_shards": 1 }, "mappings": { "properties": { "@timestamp": { "type": "date" } } }}'

curl -XPUT "http://localhost:9200/test-2" -H 'Content-Type: application/json' -d'{ "settings": { "number_of_shards": 1 }, "mappings": { "properties": { "@timestamp": { "type": "date" } } }}'

curl -XPOST "http://localhost:9200/test-*/_search" -H 'Content-Type: application/json' -d'{ "version": true, "size": 500, "sort": [ { "@timestamp": { "order": "desc", "unmapped_type": "boolean" } } ], "script_fields": { "invalid_scripted_field": { "script": { "source": "invalid", "lang": "painless" } } }, "query": { "bool": { "must": [], "filter": [ { "match_all": {} }, { "range": { "@timestamp": { "gte": "2020-03-25T20:26:57.120Z", "lte": "2020-03-25T20:41:57.120Z", "format": "strict_date_optional_time" } } } ] } }}'

PUT /test-1
{
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      }
    }
  }
}

PUT /test-2
{
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      }
    }
  }
}

POST /test-*/_search
{
  "version": true,
  "size": 500,
  "sort": [
    {
      "@timestamp": {
        "order": "desc",
        "unmapped_type": "boolean"
      }
    }
  ],
  "script_fields": {
    "invalid_scripted_field": {
      "script": {
        "source": "invalid",
        "lang": "painless"
      }
    }
  },
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "match_all": {}
        },
        {
          "range": {
            "@timestamp": {
              "gte": "2020-03-25T20:26:57.120Z",
              "lte": "2020-03-25T20:41:57.120Z",
              "format": "strict_date_optional_time"
            }
          }
        }
      ]
    }
  }
}

This failed search attempt is returning _shards and hits, where the only mention of a failure is within the _shards.failures.

{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "skipped" : 1,
    "failed" : 1,
    "failures" : [
      {
        "shard" : 0,
        "index" : "test-1",
        "node" : "3XFk8qtTTu-C0cBdpLOBPw",
        "reason" : {
          "type" : "script_exception",
          "reason" : "compile error",
          "script_stack" : [
            "invalid",
            "^---- HERE"
          ],
          "script" : "invalid",
          "lang" : "painless",
          "position" : {
            "offset" : 0,
            "start" : 0,
            "end" : 7
          },
          "caused_by" : {
            "type" : "illegal_argument_exception",
            "reason" : "variable [invalid] is not defined"
          }
        }
      }
    ]
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : 0.0,
    "hits" : [ ]
  }
}

Compare this to the previous behavior, where the response was an error with a root_cause and failed_shards:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "script_exception",
        "reason" : "compile error",
        "script_stack" : [
          "invalid",
          "^---- HERE"
        ],
        "script" : "invalid",
        "lang" : "painless",
        "position" : {
          "offset" : 0,
          "start" : 0,
          "end" : 7
        }
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "test-1",
        "node" : "3XFk8qtTTu-C0cBdpLOBPw",
        "reason" : {
          "type" : "script_exception",
          "reason" : "compile error",
          "script_stack" : [
            "invalid",
            "^---- HERE"
          ],
          "script" : "invalid",
          "lang" : "painless",
          "position" : {
            "offset" : 0,
            "start" : 0,
            "end" : 7
          },
          "caused_by" : {
            "type" : "illegal_argument_exception",
            "reason" : "variable [invalid] is not defined"
          }
        }
      }
    ]
  },
  "status" : 400
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categories>bugTeam:SearchMeta label for search teamteam-discuss

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions