Implement concurrency limits plugin - #22312
Conversation
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 56b241d. ⛔ Hard block: Issues at Medium severity or above will block this PR from merging.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
94fb671 to
56b241d
Compare
philiplhchan
left a comment
There was a problem hiding this comment.
Thanks for spending the time and effort to upstream this change. This has shown great results internally on our largest clusters, hopefully the community can benefit from it as well.
Left a few small comments.
|
Regarding the issues flagged in #22312 (comment):
I've verified the authenticity of the library (https://github.com/Netflix/concurrency-limits) and that 0.4.0 is a legitimate, official version. We might want to upgrade to 0.5.4, since it's the latest release, but the changes since 0.4.0 are fairly minimal. I also verified the SHA1 checksum matches the one from repo1.maven.org: https://repo1.maven.org/maven2/com/netflix/concurrency-limits/concurrency-limits-core/0.4.0/concurrency-limits-core-0.4.0.jar.sha1, which was last updated in 2023. (So, unless maven.org was hacked with plausible-looking last-modified timestamps, it should be fine.) I'm adding the skip-diff-analyzer label as a confirmation that the new dependencies look legit. |
PR Reviewer Guide 🔍(Review updated until commit cf8ecf7)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to cf8ecf7 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 965ec8f
Suggestions up to commit bf67dd5
Suggestions up to commit 72b0aee
Suggestions up to commit 42bcef8
Suggestions up to commit 66a8a3b
|
|
❌ Gradle check result for 56b241d: 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? |
|
@bpatelcs -- Can you please check the items in #22312 (comment) and #22312 (comment)? Also, please run |
|
Persistent review updated to latest commit fde61ad |
fde61ad to
ff2e64c
Compare
|
Persistent review updated to latest commit ff2e64c |
|
Persistent review updated to latest commit 2ecb5b1 |
|
Persistent review updated to latest commit d42b28c |
I went through the few iterations and all the new suggestions are either false positives or as design. |
|
❌ Gradle check result for d42b28c: TIMEOUT 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? |
d42b28c to
66a8a3b
Compare
|
Persistent review updated to latest commit 66a8a3b |
|
❌ Gradle check result for 66a8a3b: 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 42bcef8 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #22312 +/- ##
============================================
- Coverage 71.54% 71.43% -0.12%
+ Complexity 77023 76951 -72
============================================
Files 6153 6156 +3
Lines 358354 358430 +76
Branches 52237 52248 +11
============================================
- Hits 256399 256032 -367
- Misses 81586 82008 +422
- Partials 20369 20390 +21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Persistent review updated to latest commit 72b0aee |
|
Persistent review updated to latest commit bf67dd5 |
|
Persistent review updated to latest commit 965ec8f |
|
❌ Gradle check result for 965ec8f: 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? |
965ec8f to
cf8ecf7
Compare
|
Persistent review updated to latest commit cf8ecf7 |
|
❌ Gradle check result for cf8ecf7: 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: bhavik.patel <bhavik.patel@uber.com>
Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
- Fix operator precedence in OpenSearchVegasLimit: (int) upDriftFactor * alphaFunc... cast the double to int before multiplying, truncating fractional values (e.g. 1.5 became 1). Changed to (int) (upDriftFactor * alphaFunc...) so the product is computed as double first. - Add AtomicBoolean guard in ActionConcurrencyLimitFilter to ensure the limiter token is released exactly once. If the downstream listener throws after the wrapped listener releases the token, the outer catch would call onIgnore() a second time, double-decrementing the inflight counter. - Add test for fractional upDriftFactor (1.5 vs 1.0) proving the fractional part affects limit evolution. - Add test for double-release scenario: downstream listener throws from onResponse after token release, verifies inFlight is 0 not -1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
Tighten validatePartitionConfig to iterate only the declared partition names instead of all keys in the settings group. This prevents stray or orphan keys from contributing to the percentage sum check. Signed-off-by: Bhavik Patel <bhavik.patel@uber.com> Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
When reconfigure() transitions to DISABLED, clear the AtomicReference holding the old LimiterState so that getStats() snapshots report limit=0 instead of stale values from the previous configuration. Add testDynamicDisableClearsState to verify the snapshot is zeroed. Signed-off-by: Bhavik Patel <bhavik.patel@uber.com> Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
Add randomConcurrencyLimiterStats() to createNodeStats so the existing testSerialization round-trip covers non-null ActionConcurrencyLimiterStats. Add testConcurrencyLimiterStatsVersionGate verifying V_3_8_0 round-trips and V_3_7_0 streams exclude the field. Signed-off-by: Bhavik Patel <bhavik.patel@uber.com> Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
Cover the collectConcurrencyLimiterStats path in NodeService: - supplier present + flag true returns stats - supplier null + flag true returns null - flag false returns null regardless of supplier Signed-off-by: Bhavik Patel <bhavik.patel@uber.com> Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
Signed-off-by: bhavik.patel <bhavik.patel@uber.com>
cf8ecf7 to
9650320
Compare
Description
Adds a new concurrency-limit module that provides adaptive per-action concurrency limiting for OpenSearch. Operators can dynamically configure concurrency limits on any transport action (e.g., search, bulk) via cluster settings — no code changes required to protect new actions.
Key features
Configuration example
Files changed
Test plan
Related Issues
Resolves #22295
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.