Fix phantom WLM rejections and stats for coordinator and shard search tasks - #22839
Fix phantom WLM rejections and stats for coordinator and shard search tasks#22839LilyCaroline17 wants to merge 3 commits into
Conversation
Signed-off-by: Emily Guo <emilyguo@amazon.com>
PR Reviewer Guide 🔍(Review updated until commit d82976c)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to d82976c Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 09b367a
Suggestions up to commit f66d002
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22839 +/- ##
=========================================
Coverage 71.60% 71.61%
+ Complexity 77358 77351 -7
=========================================
Files 6170 6170
Lines 359710 359714 +4
Branches 52460 52460
=========================================
+ Hits 257583 257605 +22
+ Misses 81693 81656 -37
- Partials 20434 20453 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| try { | ||
| workloadGroupService.rejectIfNeeded(((WorkloadGroupTask) task).getWorkloadGroupId()); | ||
| } catch (OpenSearchRejectedExecutionException e) { | ||
| updatedListener.onFailure(e); |
There was a problem hiding this comment.
Right now a rejected request will count toward both total_rejections and total_completions.
You might be able to skip total_completions increment by callling setWorkloadGroupId() after the rejection check.
if (task instanceof WorkloadGroupTask workloadGroupTask) {
// Admission must precede onRequestStart (in-flight gauge) and setWorkloadGroupId
// (so a rejected task is not counted in total_completions).
try {
workloadGroupService.rejectIfNeeded(threadPool.getThreadContext().getHeader(WorkloadGroupTask.WORKLOAD_GROUP_ID_HEADER));
} catch (OpenSearchRejectedExecutionException e) {
updatedListener.onFailure(e);
return;
}
workloadGroupTask.setWorkloadGroupId(threadPool.getThreadContext());
}There was a problem hiding this comment.
Oh, I see what you mean. onTaskCompleted in WorkloadGroupService would include it in the total_completions counter since setWorkloadGroupId sets isWorkloadGroupSet to true. Good catch, thanks! Updating now.
Signed-off-by: Emily Guo <emilyguo@amazon.com>
|
Persistent review updated to latest commit 09b367a |
|
❌ Gradle check result for 09b367a: null 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? |
|
Persistent review updated to latest commit d82976c |
Description
Coordinator-level WLM search tasks were never actually rejected after resource limits were reached, and every attempted rejection produced a phantom entry in
_wlm/statswhere a task would be considered rejected when it actually ran to completion. This is because the admission check ran inWorkloadGroupRequestOperationListener.onRequestStart, inside aCompositeListenerthat swallows exceptions, so theOpenSearchRejectedExecutionExceptionnever reached the client, while rejectIfNeeded had already bumped the counters.This change moves the
rejectIfNeededcall fromWorkloadGroupRequestOperationListener.onRequestStarttoTransportSearchAction.executeRequestwhere the rejection is returned to the client with anonFailurecall. Counters now are incremented only for real rejected requests.Another issue with phantom entries in
_wlm/statswas discovered where rejected tasks for shard search tasks were also counted as completions assetWorkloadGroupId, which tags the task viaisWorkloadGroupSet, ran beforerejectIfNeededinWorkloadManagementTransportInterceptor.messageReceived. A rejected task was therefore tagged, soWorkloadGroupService.onTaskCompletedcounted it intotal_completions, meaning that a rejected task was counted as a completion.The change for this moves the
rejectIfNeededcall beforesetWorkloadGroupId, so a rejected task is never tagged and never counted as a completion.Related Issues
Resolves #22541
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.