fix(azservicebus): set minimum 60s server-timeout for management operations#26499
Open
EldertGrootenboer wants to merge 2 commits intoAzure:mainfrom
Open
fix(azservicebus): set minimum 60s server-timeout for management operations#26499EldertGrootenboer wants to merge 2 commits intoAzure:mainfrom
EldertGrootenboer wants to merge 2 commits intoAzure:mainfrom
Conversation
…ations (Azure#26421) - Add defaultServerTimeout (60s) constant and serverTimeoutMillis() helper that returns max(ctx remaining, 60s), matching .NET/Java SDK defaults - Apply to PeekMessages, ScheduleMessages, CancelScheduledMessages (mgmt.go) and RPC fallback for all other management operations (rpc.go) - Add dual-key guard in rpc.go to avoid duplicate server-timeout when operations use the vendor-prefixed com.microsoft:server-timeout key - Add 6 unit tests for serverTimeoutMillis covering all edge cases - Previously the user's context deadline was passed directly as server-timeout, causing premature timeouts on partitioned entities where the service needs up to 60s for partition scatter-gather Fixes Azure#26421
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts how server-timeout is computed and applied for Service Bus RPC-based operations to reduce premature timeouts (notably Receiver.PeekMessages() on partitioned entities), aligning behavior more closely with other language SDK defaults.
Changes:
- Introduces a
defaultServerTimeout(60s) andserverTimeoutMillis(ctx)helper that usesmax(ctx_remaining, 60s)(or 60s if no deadline). - Applies the computed server-timeout to management operations (explicitly in
mgmt.goand as an RPC fallback inrpc.go, with a dual-key guard). - Adds unit tests covering
serverTimeoutMillisbehavior across deadline/no-deadline scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sdk/messaging/azservicebus/internal/rpc.go | Ensures RPC requests include a server-timeout (unless already set), with a guard against duplicate vendor-prefixed keys. |
| sdk/messaging/azservicebus/internal/mgmt.go | Adds the 60s floor helper and applies it to management calls like Peek/Schedule/Cancel. |
| sdk/messaging/azservicebus/internal/mgmt_test.go | Adds table-driven unit tests for serverTimeoutMillis. |
| sdk/messaging/azservicebus/CHANGELOG.md | Documents the behavioral change for management operations’ server-timeout. |
…comment wording - Scope rpc.go server-timeout fallback to management operations only (com.microsoft: prefix), excluding CBS put-token requests - Update comment wording per review: 'aligns with' instead of 'matches'
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.
Problem
Receiver.PeekMessages()consistently times out withcontext deadline exceededon specific queues (#26421), whileReceiver.ReceiveMessages()on the same queue succeeds quickly.Root cause: The Go SDK passes the user's context deadline directly as the
server-timeoutAMQP application property on management RPC operations. The .NET SDK sends a fixed 60,000 ms and Java sends 59,000 ms. With typical user contexts of 10-20 seconds, the service doesn't have enough time to complete the partition scatter-gather thatPeekMessagestriggers on partitioned entities.The service-side
PeekRequestAsyncResultiterates all partitions sequentially, forwarding each peek to the partition's broker via an internal RPC link. Each hop usesRemainingTime()as its deadline, so slow partitions cascade into timeout exhaustion.ReceiveMessagesbypasses this entirely by using a direct data link to a single partition.Fix
Added a
defaultServerTimeoutconstant (60 seconds) andserverTimeoutMillis(ctx)helper that returnsmax(ctx_remaining, 60s). Applied to all management operation enforcement points:mgmt.go—PeekMessages,ScheduleMessages,CancelScheduledMessages(explicit)rpc.go— RPC fallback coveringReceiveDeferred,RenewLocks,RenewSessionLock,GetSessionState,SetSessionState,SettleOnMgmtLinkThe user's context still governs client-side cancellation (the
selectonctx.Done()inrpc.gois unchanged). The fix only affects theserver-timeoutvalue sent to the service, giving it sufficient headroom for partition scatter-gather.Design decisions
max(remaining, 60s). This respects users who set longer timeouts (e.g., 120s) while establishing a floor that matches cross-SDK parity.rpc.go:ScheduleMessages/CancelScheduledMessagesuse the vendor-prefixed keycom.microsoft:server-timeoutwhilePeekMessagesand the RPC fallback useserver-timeout. The guard now checks both keys to avoid sending a duplicate property.server-timeoutwas sent whenctxhad no deadline. Now60000is always sent, matching .NET/Java behavior.Testing
6 table-driven unit tests for
serverTimeoutMilliscovering: no deadline, short deadline (10s floor), very short (1s floor), long deadline (120s respected), exact boundary (60s), and expired context. All pass.Full module suite: 10/10 test packages pass,
go vetclean,gofmtclean.Cross-SDK Parity
server-timeoutServiceBusRetryOptions.cs,AmqpRequestMessage.csServiceBusConstants.java,MessageUtils.javamax(ctx_remaining, 60,000)msmgmt.go:serverTimeoutMillis()Fixes #26421