Skip to content

[Automated] Update API Surface Area#2

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
update-api-diffs
Open

[Automated] Update API Surface Area#2
github-actions[bot] wants to merge 1 commit into
mainfrom
update-api-diffs

Conversation

@github-actions

@github-actions github-actions Bot commented May 6, 2025

Copy link
Copy Markdown

Auto-generated update to the API surface to compare current surface vs latest release. This should only be merged once this surface area ships in a new release.

rkargMsft pushed a commit that referenced this pull request Jun 14, 2026
Three concurrency bugs surfaced by post-PR adversarial review of LocalReminderDeliveryThrottle and fixed with regression tests:

1. Concurrency permit leak when rate-acquire phase throws OperationCanceledException. The rate-acquire call is now wrapped in try/catch that releases the previously-acquired concurrency permit before rethrowing. Under the previous code, every in-flight reminder waiting on a rate token at silo shutdown would permanently consume a concurrency permit.

2. Concurrency permit leak in WaitSemaphoreWithTimeoutAsync when the timeout fires at the same instant the semaphore grants. The previous implementation used a ContinueWith(_ => true) projection that erased the distinction between a successful grant and a cancelled wait; if the delay won the WhenAny race after the grant succeeded, the permit was held but no caller was tracking it. Replaced with a single linked-token CTS that relies on SemaphoreSlim.WaitAsync's documented atomic grant-or-cancel contract.

3. Rate-acquire deadline math used TimeProvider.System.TimestampFrequency to scale seconds-to-ticks while comparing against _timeProvider.GetTimestamp() from a configurable TimeProvider. On platforms where Stopwatch.Frequency differs from the configured TimeProvider's frequency (e.g., Linux, or any test using FakeTimeProvider with a non-default frequency), the WaitWithTimeout rate path would terminate early or hang. Rewritten to use TimeSpan-based comparison via _timeProvider.GetElapsedTime, eliminating cross-provider unit mixing.

Regression tests: Cancellation_DuringRateWait_ReleasesConcurrencyPermit verifies #1 by driving the test throttle into the rate-wait state then cancelling. WaitUpTo_OnRateLimitedPath_SkipsWhenWaitExceedsTimeout exercises the corrected #3 deadline path on a FakeTimeProvider. Issue #2 is verified by inspection of the new implementation; the contract is now a direct consequence of SemaphoreSlim.WaitAsync's semantics.

All 28 tests (21 unit + 5 cluster integration + 2 new regression) pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rkargMsft pushed a commit that referenced this pull request Jun 17, 2026
Three concurrency bugs surfaced by post-PR adversarial review of LocalReminderDeliveryThrottle and fixed with regression tests:

1. Concurrency permit leak when rate-acquire phase throws OperationCanceledException. The rate-acquire call is now wrapped in try/catch that releases the previously-acquired concurrency permit before rethrowing. Under the previous code, every in-flight reminder waiting on a rate token at silo shutdown would permanently consume a concurrency permit.

2. Concurrency permit leak in WaitSemaphoreWithTimeoutAsync when the timeout fires at the same instant the semaphore grants. The previous implementation used a ContinueWith(_ => true) projection that erased the distinction between a successful grant and a cancelled wait; if the delay won the WhenAny race after the grant succeeded, the permit was held but no caller was tracking it. Replaced with a single linked-token CTS that relies on SemaphoreSlim.WaitAsync's documented atomic grant-or-cancel contract.

3. Rate-acquire deadline math used TimeProvider.System.TimestampFrequency to scale seconds-to-ticks while comparing against _timeProvider.GetTimestamp() from a configurable TimeProvider. On platforms where Stopwatch.Frequency differs from the configured TimeProvider's frequency (e.g., Linux, or any test using FakeTimeProvider with a non-default frequency), the WaitWithTimeout rate path would terminate early or hang. Rewritten to use TimeSpan-based comparison via _timeProvider.GetElapsedTime, eliminating cross-provider unit mixing.

Regression tests: Cancellation_DuringRateWait_ReleasesConcurrencyPermit verifies #1 by driving the test throttle into the rate-wait state then cancelling. WaitUpTo_OnRateLimitedPath_SkipsWhenWaitExceedsTimeout exercises the corrected #3 deadline path on a FakeTimeProvider. Issue #2 is verified by inspection of the new implementation; the contract is now a direct consequence of SemaphoreSlim.WaitAsync's semantics.

All 28 tests (21 unit + 5 cluster integration + 2 new regression) pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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