[release/10.0] Fix NoopLimiter disposal in DefaultPartitionedRateLimiter Heartbeat - #133647
Open
github-actions[bot] wants to merge 3 commits into
Open
github-actions[bot] wants to merge 3 commits into
github-actions[bot] wants to merge 3 commits into
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @VSadov |
…127582) Fixes `DefaultPartitionedRateLimiter` so that `NoopLimiter` partitions are evicted and disposed by the Heartbeat timer, which previously never happened because `NoopLimiter.IdleDuration` always returns `null`. ## Changes Made - Introduced a `LimiterEntry` wrapper that tracks a `LastAccessTimestamp` (updated on each `Acquire`/`WaitAsync` call) alongside the `RateLimiter` instance. - Added `GetIdleDuration(LimiterEntry)` helper that falls back to the elapsed time since last access for `NoopLimiter` (whose `IdleDuration` is always `null`), and returns `null` for all other limiter types that return `null` (preserving the existing "do not evict" contract). - Updated the Heartbeat eviction check to use the `is TimeSpan idleDuration && idleDuration > s_idleTimeLimit` pattern (with `?? TimeSpan.Zero` for the under-lock re-check), correctly handling the nullable `TimeSpan?` return — `null` skips eviction, matching the original pattern. - Used `Volatile.Read`/`Volatile.Write` for atomic 64-bit timestamp access on 32-bit platforms. - Added a `RateLimiterHelper.GetElapsedTime(long)` overload to avoid `.GetValueOrDefault()` at call sites. - Added tests covering `NoopLimiter` eviction via Heartbeat and verifying that non-`NoopLimiter` partitions with `IdleDuration == null` are not evicted while active. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: VSadov <8218165+VSadov@users.noreply.github.com> Co-authored-by: Vladimir Sadov <vsadov@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
github-actions
Bot
force-pushed
the
backport/pr-127582-to-release/10.0
branch
from
September 14, 2026 17:58
78e27af to
85f3f55
Compare
agocke
approved these changes
Sep 17, 2026
Member
|
@agocke fyi there are build failures |
Member
|
@copilot please fix conflicts |
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Contributor
The branch already includes the current |
This branch has not been deployed
This file contains hidden or 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
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.
Backport of #127582 to release/10.0
/cc @agocke @copilot
Customer Impact
DefaultPartitionedRateLimiter never disposes NoopLimiter leading to memory leak and increased CPU usage as it performs its internal work on list of all limiters every 100ms.
Regression
Looks like this code existed all the way back to at least .NET 7.
Testing
New unit tests added, change validated by user.
Risk
Low