From 87110b5acc463e7a4b94629e66aadb8becad083f Mon Sep 17 00:00:00 2001 From: David Zane Date: Fri, 26 Jan 2024 10:48:07 -0800 Subject: [PATCH] [Bug] Check phase name before SearchRequestOperationsListener onPhaseStart Signed-off-by: David Zane --- CHANGELOG.md | 1 + .../opensearch/action/search/AbstractSearchAsyncAction.java | 5 ++++- .../org/opensearch/action/search/TransportSearchAction.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa31819ffae97..5fab88d418f10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Update supported version for max_shard_size parameter in Shrink API ([#11439](https://github.com/opensearch-project/OpenSearch/pull/11439)) - Fix typo in API annotation check message ([11836](https://github.com/opensearch-project/OpenSearch/pull/11836)) - Update supported version for must_exist parameter in update aliases API ([#11872](https://github.com/opensearch-project/OpenSearch/pull/11872)) +- [Bug] Check phase name before SearchRequestOperationsListener onPhaseStart ([#12035](https://github.com/opensearch-project/OpenSearch/pull/12035)) ### Security diff --git a/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java b/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java index 5b41c2a13b596..30c91e86da8e8 100644 --- a/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java @@ -441,7 +441,10 @@ private void onPhaseEnd(SearchRequestContext searchRequestContext) { private void onPhaseStart(SearchPhase phase) { setCurrentPhase(phase); - this.searchRequestContext.getSearchRequestOperationsListener().onPhaseStart(this); + try { + SearchPhaseName.valueOf(phase.getSearchPhaseName().toString()); + this.searchRequestContext.getSearchRequestOperationsListener().onPhaseStart(this); + } catch (IllegalArgumentException ignored) {} } private void onRequestEnd(SearchRequestContext searchRequestContext) { diff --git a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java index 842c10b700d24..79e599ec9387b 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java @@ -1238,7 +1238,7 @@ private AbstractSearchAsyncAction searchAsyncAction clusters, searchRequestContext ); - return new SearchPhase(action.getName()) { + return new SearchPhase("none") { @Override public void run() { action.start();