-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Bugfix] Fix IllegalArgumentException thrown when creating a PIT #16781
base: main
Are you sure you want to change the base?
[Bugfix] Fix IllegalArgumentException thrown when creating a PIT #16781
Conversation
Signed-off-by: Peter Alfonsi <petealft@amazon.com>
❌ Gradle check result for 6d35c7e: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Peter Alfonsi <petealft@amazon.com>
Flaky test: #14293 |
❌ Gradle check result for ea30484: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
server/src/main/java/org/opensearch/action/search/SearchRequestStats.java
Show resolved
Hide resolved
Signed-off-by: Peter Alfonsi <petealft@amazon.com>
2ac0920
to
a41f9be
Compare
❌ Gradle check result for a41f9be: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Flaky test: #16576 |
Signed-off-by: Peter Alfonsi <petealft@amazon.com>
❕ Gradle check result for e20a4de: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16781 +/- ##
============================================
- Coverage 72.19% 72.11% -0.09%
+ Complexity 65274 65187 -87
============================================
Files 5318 5318
Lines 303993 303999 +6
Branches 43990 43990
============================================
- Hits 219461 219222 -239
- Misses 66517 66774 +257
+ Partials 18015 18003 -12 ☔ View full report in Codecov by Sentry. |
@@ -73,20 +73,32 @@ public long getTookMetric() { | |||
|
|||
@Override | |||
protected void onPhaseStart(SearchPhaseContext context) { | |||
phaseStatsMap.get(context.getCurrentPhase().getSearchPhaseName()).current.inc(); | |||
try { | |||
phaseStatsMap.get(context.getCurrentPhase().getSearchPhaseName()).current.inc(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I count 4 method calls in this line. The problem with this try-catch is that any one of them in theory could throw an IllegalArgumentException, and you probably don't want to swallow it in all cases. Also, exception handling in the control flow is generally something to avoid.
I might recommend revisiting that API on SearchPhase
to make it explicit that it may not be possible to get a SearchPhaseName
. Like if it returned an Optional you could do:
phase.asSearchPhaseName().ifPresent(name -> {
phaseStatsMap.get(name).current.inc();
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I've just pushed a commit changing getSearchPhaseName
to return Optional<SearchPhaseName>
.
Signed-off-by: Peter Alfonsi <petealft@amazon.com>
60b90af
to
49fec57
Compare
❌ Gradle check result for 49fec57: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Description
Fixes
java.lang.IllegalArgumentException: No enum constant org.opensearch.action.search.SearchPhaseName.CREATE_PIT
which is thrown when creating a PIT.The exception comes from SearchRequestStats. It doesn't track PIT stats as this is handled elsewhere. So, when it got search phases with the name "create_pit", it couldn't find a matching enum value and threw the error. Adds a try-catch block on search phase start/end/failure so that if no matching enum value is found, nothing happens.
Adds UTs. Also, manually tested that after making the change, the following commands no longer caused the exception:
curl -XPOST "http://localhost:9200/test-index/_doc/1?op_type=index" -H "Content-Type: application/json" -d '{ "field1": "value1", "field2": "value2", "field3": 123 }'
curl -XPOST "http://localhost:9200/test-index/_search/point_in_time?keep_alive=1h"
And confirmed the new catch-all doesn't show up in the output of
curl -XGET "localhost:9200/_nodes/stats/indices/search"
.Related Issues
Resolves #16750
Check List
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.