[fix][broker] Unthrottle producers immediately when publish rate limiting is disabled - #25502
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR ensures producers are unthrottled immediately when publish rate limiting is disabled, avoiding long waits from previously scheduled delayed unthrottle tasks.
Changes:
- Cache the
ScheduledExecutorServiceused for unthrottling after the first throttling event. - When
update(null)disables rate limiting, trigger unthrottling immediately (0 delay) using the cached executor.
|
The current fix, via Sorry, the code version I was looking at doesn't seem to be the latest. |
@thetumbled did the problem happen also with the fix in #25262 and #25269? |
We haven't encountered this problem in our production environment yet. Since the bucket value is allowed to be negative, I am concerned that the producer may get stuck for a long time. We need a way to disable the throttling feature as quickly as possible. |
lhotari
left a comment
There was a problem hiding this comment.
LGTM, a few comments to address.
|
Maybe a test should be added to verify that the fix actually works. Otherwise, there's no way to fully confirm whether issues similar to #25502 (comment) still exist — the scope of manual review is always limited. |
I will add one later. |
|
Tests have been added. You can comment out the call to |
…ting is disabled (apache#25502) Co-authored-by: fengwenzhi <fengwenzhi.max@bigo.sg> (cherry picked from commit 85937d8)

Motivation
When publish rate limiting is disabled (for example by clearing the publish rate policy so update(null) is called), token buckets are nulled out immediately, but producers that were already throttled could remain blocked until a previously scheduled unthrottle task ran. That delayed task may have been scheduled with a very long wait time when the token bucket was deeply depleted, so disabling the limit in configuration did not restore traffic quickly. This change triggers the existing lock-free unthrottle path right away after disablement when an executor was already cached from a prior throttle on this limiter.
Modifications
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes