Skip to content

fix(rpc): release concurrent count when downstream throws LIMIT_EXCEEDED - #16461

Open
Lubaoshuai wants to merge 2 commits into
apache:3.3from
Lubaoshuai:fix/limit-filter-count-leak
Open

Lubaoshuai wants to merge 2 commits into
apache:3.3from
Lubaoshuai:fix/limit-filter-count-leak

Conversation

@Lubaoshuai

Copy link
Copy Markdown

Fixes #16455

What

ActiveLimitFilter and ExecuteLimitFilter skipped RpcStatus.endCount() whenever onError received a LIMIT_EXCEEDED RpcException. That skip is only correct when the filter itself rejected admission (in that case beginCount never succeeded, so there is nothing to release).

When admission succeeded and a downstream invoker (client side, ActiveLimitFilter) or the business implementation (provider side, ExecuteLimitFilter) threw LIMIT_EXCEEDED — or a response future completed exceptionally with it — the count taken in invoke() leaked. Repeated occurrences exhaust the actives/executes slots and every subsequent invocation times out until restart.

Fix

Mark the invocation (invocation.put(...COUNTED, true)) as soon as beginCount succeeds. onError now only skips the release when a LIMIT_EXCEEDED arrives without that marker (i.e. the filter's own rejection path); every other error — and downstream limit exceptions — release the count as before.

Tests

Two regression cases per filter in dubbo-rpc-api:

  • downstream/business LIMIT_EXCEEDED after successful admission → the slot is released (active == 0); previously it leaked,
  • admission rejected by the filter itself → the concurrent count is untouched (no double release).

ActiveLimitFilterTest (9) and ExecuteLimitFilterTest (6) all pass.

…DED (apache#16455)

ActiveLimitFilter and ExecuteLimitFilter skipped RpcStatus.endCount()
whenever onError received a LIMIT_EXCEEDED RpcException. That skip is
only correct when the filter itself rejected admission (beginCount never
succeeded). When admission succeeded and a downstream invoker or the
business implementation threw LIMIT_EXCEEDED, the count taken in
invoke() leaked, eventually exhausting the actives/executes slots.

Mark the invocation once beginCount succeeds and only skip the release
when that marker is absent.

Signed-off-by: Lubaoshuai <128781758+Lubaoshuai@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.92%. Comparing base (dab47b7) to head (16a8b39).

Files with missing lines Patch % Lines
...org/apache/dubbo/rpc/filter/ActiveLimitFilter.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16461      +/-   ##
============================================
  Coverage     60.91%   60.92%              
- Complexity       15    11766   +11751     
============================================
  Files          1953     1953              
  Lines         89271    89273       +2     
  Branches      13473    13473              
============================================
+ Hits          54383    54389       +6     
- Misses        29309    29313       +4     
+ Partials       5579     5571       -8     
Flag Coverage Δ
integration-tests-java21 32.13% <0.00%> (+<0.01%) ⬆️
integration-tests-java8 32.21% <0.00%> (-0.01%) ⬇️
samples-tests-java21 32.16% <0.00%> (+<0.01%) ⬆️
samples-tests-java8 29.75% <0.00%> (-0.09%) ⬇️
unit-tests-java11 59.17% <75.00%> (+0.01%) ⬆️
unit-tests-java17 58.65% <75.00%> (-0.01%) ⬇️
unit-tests-java21 58.63% <75.00%> (-0.02%) ⬇️
unit-tests-java25 58.61% <75.00%> (+<0.01%) ⬆️
unit-tests-java8 59.21% <75.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Lubaoshuai <128781758+Lubaoshuai@users.noreply.github.com>
@Lubaoshuai
Lubaoshuai force-pushed the fix/limit-filter-count-leak branch from e836c66 to 16a8b39 Compare September 13, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Concurrency limit filters leak active counts on downstream limit exceptions

2 participants