Skip to content

[BUG] HTTP status code changed on 2.3.0 on querying for non-existing index #851

Closed

Description

@Yury-Fridlyand

How can one reproduce the bug?

curl -v -s -XPOST "http://localhost:9200/_plugins/_sql" -H 'Content-Type: application/json' -d "{\"query\": \"select * from non-existed\"}"

OpenSearch 2.2.1:

HTTP/1.1 400 Bad Request
{
  "error": {
    "reason": "Error occurred in OpenSearch engine: no such index [non-existed]",
    "details": "org.opensearch.index.IndexNotFoundException: no such index [non-existed]\nFor more details, please send request for Json format to see the raw response from OpenSearch engine.",
    "type": "IndexNotFoundException"
  },
  "status": 404
}

2.3.0:

HTTP/1.1 503 Service Unavailable
{
  "error": {
    "reason": "Error occurred in OpenSearch engine: no such index [non-existed]",
    "details": "org.opensearch.index.IndexNotFoundException: no such index [non-existed]\nFor more details, please send request for Json format to see the raw response from OpenSearch engine.",
    "type": "IndexNotFoundException"
  },
  "status": 404
}

Payloads are same, but status codes are different.

Activity

  1. added
    bug
    on Sep 20, 2022
  2. dai-chen commented on Sep 21, 2022

    @dai-chen
    Collaborator

    Thanks for reporting this issue! This is probably because the approach of getting index mapping is changed. Previously the code on each OpenSearch node just read status in ClusterState object locally. In this way, we can avoid blocking operation during parsing, analyzing and planning and make all running on NIO thread. However, this is changed to calling OpenSearch API due to some other issue.

    Previously index not found exception is thrown and handled by https://github.com/opensearch-project/sql/blob/2.2/legacy/src/main/java/org/opensearch/sql/legacy/plugin/RestSqlAction.java#L165 in NIO thread. Now it's thrown from worker thread and handled by https://github.com/opensearch-project/sql/blob/2.2/legacy/src/main/java/org/opensearch/sql/legacy/plugin/RestSQLQueryAction.java#L177 without isClientError check. We may need to check here as we move everything to worker thread.

  3. acarbonetto commented on Sep 28, 2022

    @acarbonetto
    Collaborator

    Test skipped for change:

    @pytest.mark.skip(reason="Test is not compatible with OpenSearch >= 2.3.0, it returns HTTP/503 instead of HTTP/400")

  4. dai-chen commented on Feb 8, 2023

    @dai-chen
    Collaborator

    I found similar issue in metrics. In legacy engine, index not found is treated as client error. However, the issue reported here cause it treated as server error in v2 engine which may cause wrong alarm in monitor system from user side.

  5. self-assigned this
    on Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

SQLbugv2.6.0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions