fix(rpc): release concurrent count when downstream throws LIMIT_EXCEEDED by Lubaoshuai · Pull Request #16461 · apache/dubbo · GitHub
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

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

This branch has not been deployed

No deployments
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