Add dedicated analytics_scheduler thread pool to prevent deadlock#21771
Conversation
PR Reviewer Guide 🔍(Review updated until commit 7200ad7)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 7200ad7 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 3522e69
Suggestions up to commit dbe4099
|
On single-node clusters (or when shards are colocated with the coordinator), the reduce stage and fragment execution both competed for the SEARCH thread pool. With N concurrent analytics queries each holding a SEARCH thread for reduce, fragment handlers would queue behind them — causing deadlock when N >= pool size. Fix: introduce a dedicated analytics_coordinator pool (max(2, cpus/2) threads, queue=100) for coordinator reduce/passthrough stages. Fragment execution remains on SEARCH. The two layers can never starve each other since they use separate pools. Changes: - AnalyticsPlugin: register analytics_coordinator FixedExecutorBuilder - QueryContext: accept ThreadPool instead of individual Executors, expose searchExecutor() and coordinatorExecutor() accessors - ReduceStageExecution/PassThroughStageExecution: use coordinatorExecutor() - DefaultPlanExecutor: pass ThreadPool to QueryContext Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
dbe4099 to
54349fd
Compare
|
Persistent review updated to latest commit 3522e69 |
|
❌ Gradle check result for 3522e69: 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? |
|
❌ Gradle check result for 3522e69: 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? |
|
❌ Gradle check result for 3522e69: 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? |
|
Persistent review updated to latest commit 7200ad7 |
|
❌ Gradle check result for 7200ad7: 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? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21771 +/- ##
============================================
- Coverage 73.44% 73.36% -0.09%
+ Complexity 75084 75033 -51
============================================
Files 6016 6016
Lines 341072 341072
Branches 49091 49091
============================================
- Hits 250513 250216 -297
- Misses 70641 70884 +243
- Partials 19918 19972 +54 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…stype_join Reconciles M1 broadcast branch with origin/main (PR opensearch-project#21771: dedicated analytics_coordinator thread pool). Resolutions: - AnalyticsPlugin.java: keep HEAD's SettingsFilter import (still used by M1's getRestHandlers override for /_analytics/_strategies). - QueryContext.java: keep main's threadPool-based contract (replaces M1's searchExecutor field) plus HEAD's SharedState holder for phased contexts. Update three call sites (public ctor, withDag, forTest) to pass threadPool + new SharedState() — the stale searchExecutor refs on the HEAD side were leftovers from before the field rename. Verified: full :sandbox:plugins:analytics-engine:test suite green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…pensearch-project#21771) On single-node clusters (or when shards are colocated with the coordinator), the reduce stage and fragment execution both competed for the SEARCH thread pool. With N concurrent analytics queries each holding a SEARCH thread for reduce, fragment handlers would queue behind them — causing deadlock when N >= pool size. Fix: introduce a dedicated analytics_scheduler pool (max(2, cpus/2) threads, queue=100) for coordinator reduce/passthrough stages. Fragment execution remains on SEARCH. The two layers can never starve each other since they use separate pools. Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
Introduce a dedicated analytics_scheduler thread pool (max(2, cpus/2) threads) for orchestration/wait. The reduce stage is dispatched on this scheduler pool, which immediately forks the actual reduce computation to SEARCH.
Fragment execution stays on SEARCH. The two layers can never starve each other.
Thread responsibilities after the change:
Changes:
Description
[Describe what this change achieves]
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
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.