Repository navigation
[DurableTask.ServiceBus] Honor operationTimeout in SessionClient.AcceptMessageSessionAsync - #1426
Open
Davide Montanari (davidemontanari) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in the focused timeout change or regression tests; tests were not executed.
No open issues 🎉
What changed in this PR
Updates the Service Bus session abstraction to honor the caller’s receive timeout instead of relying solely on the SDK timeout.
Changes:
- Passes a timed cancellation token when
operationTimeoutis positive. - Returns
nullon timeout while preserving non-positive timeout behavior and propagating unrelated errors. - Adds six regression tests covering successful acceptance, timeout handling, and error propagation.
| File | Description |
|---|---|
| test/DurableTask.ServiceBus.Tests/SessionClientTests.cs | Adds fake-client tests for session acceptance and timeout behavior. |
| src/DurableTask.ServiceBus/Common/Abstraction/ServiceBusAbstraction.cs | Enforces the requested session-accept timeout and documents fallback behavior. |
Review effort: Balanced
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.
Summary
SessionClient.AcceptMessageSessionAsync(TimeSpan operationTimeout)ignored itsoperationTimeoutparameter. The call toServiceBusClient.AcceptNextSessionAsyncwas not given a cancellation token, so an empty accept waited for the SDK'sTryTimeout(60s by default; this project doesn't configure it) instead of the timeout the caller requested.Callers (
LockNextTaskOrchestrationWorkItemAsyncandFetchTrackingWorkItemAsync) pass the dispatcher'sDefaultReceiveTimeout(30s), so the effective wait was twice what the dispatcher reports in itsStartFetch/FetchWorkItemStartingtraces.Changes
AcceptMessageSessionAsyncnow creates aCancellationTokenSource(operationTimeout)whenoperationTimeout > TimeSpan.Zeroand passes its token toAcceptNextSessionAsync.null, the existing "no session available" result, the same as the existingServiceTimeoutpath. The dispatcher re-polls immediately with no backoff, as before.catchis filtered withwhen (timeoutCts.IsCancellationRequested), so cancellations from other sources are still propagated.operationTimeoutkeeps the previous behavior, where the wait is limited only by the SDK'sTryTimeout.Impact
AcceptNextSessionAsyncis a long poll and returns as soon as a session becomes available.Tests
Added
SessionClientTests(net8.0 and net48), using fakeServiceBusClient/ServiceBusSessionReceiversubclasses:nullshortly afteroperationTimeoutelapses, and the accept token is cancelled;nullonServiceBusFailureReason.ServiceTimeout;operationTimeoutis non-positive;OperationCanceledExceptionnot caused by the timeout;ServiceBusExceptions.Without the fix, the timeout test fails (the call returns after about 10s); all 6 tests pass with it.