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

Fix index not found reported as server error bug #1353

Merged

Conversation

dai-chen
Copy link
Collaborator

@dai-chen dai-chen commented Feb 16, 2023

Description

IndexNotFoundException thrown from OpenSearch get index mapping API is treated as server error. This caused breaking behavior as reported in issue below. More importantly, this may cause false alarm if monitoring logic on SQL plugin.

Root Cause

Due to security concern, we switched from OpenSearch's ClusterService.getIndexMapping() to our current OpenSearchNodeClient.getIndexMapping(). OpenSearchNodeClient captures every exception thrown from underlying OpenSearch API, including IndexNotFoundException, and wrap it by IllegalStateException. On the high level, isClientError() determines if this is a client error on IllegalStateException instead of the IndexNotFoundException wrapped inside.

Quick Fix

  1. Capture IndexNotFoundException individually and re-throw it directly to fix the issue
  2. Add IT in PPLPluginIT because no better place in SQL IT. Confirmed it can reproduce the issue without the fix
  3. Clean up the unused resolver field and mockNodeClient() handy

Issues Resolved

#851

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dai-chen dai-chen added bug Something isn't working backport 2.x labels Feb 16, 2023
@dai-chen dai-chen self-assigned this Feb 16, 2023
Yury-Fridlyand
Yury-Fridlyand previously approved these changes Feb 16, 2023
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an integration test which proves the fix in the end-to-end flow?

Signed-off-by: Chen Dai <[email protected]>
@dai-chen
Copy link
Collaborator Author

Maybe add an integration test which proves the fix in the end-to-end flow?

Yes, just found a place to add it.

@codecov-commenter
Copy link

Codecov Report

Merging #1353 (911c769) into main (114e02a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff            @@
##               main    #1353   +/-   ##
=========================================
  Coverage     98.38%   98.38%           
  Complexity     3693     3693           
=========================================
  Files           343      343           
  Lines          9106     9107    +1     
  Branches        585      585           
=========================================
+ Hits           8959     8960    +1     
  Misses          142      142           
  Partials          5        5           
Flag Coverage Δ
sql-engine 98.38% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ch/sql/opensearch/client/OpenSearchNodeClient.java 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@dai-chen dai-chen marked this pull request as ready for review February 16, 2023 23:27
@dai-chen dai-chen requested a review from a team as a code owner February 16, 2023 23:27
@dai-chen dai-chen merged commit 76a8d29 into opensearch-project:main Feb 17, 2023
@dai-chen dai-chen deleted the fix-index-not-found-server-error branch February 17, 2023 17:25
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 17, 2023
* Capture IndexNotFoundException and re-throw directly

Signed-off-by: Chen Dai <[email protected]>

* Add IT

Signed-off-by: Chen Dai <[email protected]>

---------

Signed-off-by: Chen Dai <[email protected]>
(cherry picked from commit 76a8d29)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 17, 2023
* Capture IndexNotFoundException and re-throw directly

Signed-off-by: Chen Dai <[email protected]>

* Add IT

Signed-off-by: Chen Dai <[email protected]>

---------

Signed-off-by: Chen Dai <[email protected]>
(cherry picked from commit 76a8d29)
dai-chen added a commit that referenced this pull request Feb 17, 2023
* Capture IndexNotFoundException and re-throw directly

Signed-off-by: Chen Dai <[email protected]>

* Add IT

Signed-off-by: Chen Dai <[email protected]>

---------

Signed-off-by: Chen Dai <[email protected]>
(cherry picked from commit 76a8d29)

Co-authored-by: Chen Dai <[email protected]>
dai-chen added a commit that referenced this pull request Feb 17, 2023
* Capture IndexNotFoundException and re-throw directly

Signed-off-by: Chen Dai <[email protected]>

* Add IT

Signed-off-by: Chen Dai <[email protected]>

---------

Signed-off-by: Chen Dai <[email protected]>
(cherry picked from commit 76a8d29)

Co-authored-by: Chen Dai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport 2.5 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] HTTP status code changed on 2.3.0 on querying for non-existing index
4 participants