Skip to content

per-key rate limit should block at priority level, not whole queue#10188

Draft
majiru wants to merge 1 commit intotemporalio:mainfrom
majiru:OSSM-387
Draft

per-key rate limit should block at priority level, not whole queue#10188
majiru wants to merge 1 commit intotemporalio:mainfrom
majiru:OSSM-387

Conversation

@majiru
Copy link
Copy Markdown
Contributor

@majiru majiru commented May 6, 2026

When findAndWakeMatches found a rate-limited task it set a retry timer and returned immediately, stalling every task behind it regardless of fairness key. A high-priority key1 task being throttled would block a ready key2 task from dispatching until the timer fired.

The fix moves the rate-limit check inside findMatch. The inner poller loop now saves the first compatible poller in matched rather than returning immediately. After finding a poller, the task's rate-limit delay is checked: if positive the task is skipped and its delay contributes to a running minDelay; if zero the match is returned. findMatch gains a third return value carrying minDelay back to findAndWakeMatches, which uses it to set the retry timer only when there are no ready matches at all — and only to the earliest time any blocked task (that actually has a compatible poller) becomes ready.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

When findAndWakeMatches found a rate-limited task it set a retry timer
and returned immediately, stalling every task behind it regardless of
fairness key. A high-priority key1 task being throttled would block a
ready key2 task from dispatching until the timer fired.

The fix moves the rate-limit check inside findMatch. The inner poller
loop now saves the first compatible poller in `matched` rather than
returning immediately. After finding a poller, the task's rate-limit
delay is checked: if positive the task is skipped and its delay
contributes to a running `minDelay`; if zero the match is returned.
findMatch gains a third return value carrying minDelay back to
findAndWakeMatches, which uses it to set the retry timer only when
there are no ready matches at all — and only to the earliest time any
blocked task (that actually has a compatible poller) becomes ready.
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.

1 participant