-
Notifications
You must be signed in to change notification settings - Fork 937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix task queue rate-limit for invalid tasks #7590
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Carly de Frondeville <[email protected]>
yiminc
reviewed
Apr 8, 2025
prathyushpv
reviewed
Apr 9, 2025
prathyushpv
approved these changes
Apr 11, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changed?
Implement
RecycleToken
inMultiRateLimiter
and add functional tests.Why?
ClockedRateLimiter
is the base rate limiter for many rate limiters in our system, so I made the mistake of assuming that implementingRecycleToken
there and and then callingClockedRateLimiter.RecycleToken
from other wrapper rate limiters (such asMultiRateLimiter
andDynamicRateLimiter
) would "just work."However, a limitation of the recycle token implementation is that another process must be waiting on a token (via
ClockedRateLimiter.Wait
) at the time whenRecycleToken
is called.DynamicRateLimiter.Wait
callsClockedRateLimiter.Wait
, which means thatDynamicRateLimiter.RecycleToken
can simply callClockedRateLimiter.RecycleToken
.However,
MultiRateLimiter.Wait
does not call theWait
method of its sub-rate-limiters; instead it implements a customWait
method using theReserve
methods of its sub-rate-limiters. This means the sub-rate-limiters never callWait
and never wait for the recycled token to arrive. GivingMultiRateLimiter
a customRecycleToken
implementation that pairs with the customMultiRateLimiter.Wait
solves this problem.How did you test it?
Tested in a test server using sample workflows, and with functional tests for old and new matcher.
Note that New Matcher did not have this bug, because it does not use
MultiRateLimiter
for task queue rate limiting.Potential risks
Documentation
Is hotfix candidate?
It fixes a bug, but the bug only occurs when many workflows that have backlogged tasks become invalid (ie. via termination or deletion).