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

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

Closed
Yury-Fridlyand opened this issue Sep 20, 2022 · 3 comments · Fixed by #1353
Closed

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

Yury-Fridlyand opened this issue Sep 20, 2022 · 3 comments · Fixed by #1353
Assignees
Labels
bug Something isn't working SQL v2.6.0

Comments

@Yury-Fridlyand
Copy link
Collaborator

Yury-Fridlyand commented Sep 20, 2022

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.

@Yury-Fridlyand Yury-Fridlyand added bug Something isn't working untriaged labels Sep 20, 2022
@dai-chen
Copy link
Collaborator

dai-chen commented Sep 21, 2022

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.

@dai-chen dai-chen added SQL and removed untriaged labels Sep 21, 2022
@acarbonetto
Copy link
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")

@dai-chen
Copy link
Collaborator

dai-chen commented Feb 8, 2023

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.

@dai-chen dai-chen added the v2.6.0 label Feb 8, 2023
@dai-chen dai-chen self-assigned this Feb 16, 2023
@dai-chen dai-chen linked a pull request Feb 16, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working SQL v2.6.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants