Repository navigation
fix(streaming): release Azure Queue messages during handoff - #11144
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The current shutdown-during-receive path can still perform message release using CancellationToken.None, which can ignore the shutdown budget and potentially hang shutdown/receive completion under stalled Azure operations.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/AzureQueueAdapterReceiver.cs — When shutdown begins during a receive, this branch clears pendingDeliveries, which later triggers… |
What changed in this PR
This PR addresses a reliability gap in the Azure Queue streaming receiver during graceful ownership handoff: prefetched but unacknowledged messages could remain hidden until their visibility timeout, delaying redelivery on the replacement silo and causing flaky “9 of 10 deliveries” timeouts.
Changes:
- Update the Azure Queue receiver shutdown path to track in-flight operations and proactively release pending (unacknowledged) messages by resetting visibility.
- Introduce an internal
IAzureQueueDataManagerseam and add message-release support inAzureQueueDataManagerviaUpdateMessageAsync. - Add targeted unit + Azurite-backed functional coverage and document graceful handoff behavior/permissions.
| File | Description |
|---|---|
| test/Extensions/Orleans.Azure.Tests/Streaming/AzureQueueAdapterTests.cs | Adds an Azurite-backed functional regression test asserting pending messages are redelivered promptly after receiver shutdown. |
| test/Extensions/Orleans.Azure.Tests/Streaming/AzureQueueAdapterReceiverTests.cs | Adds deterministic unit tests for shutdown release, late-receive races, successful delete, and delete-failure behavior. |
| src/Azure/Orleans.Streaming.AzureStorage/Utilities/AzureQueueErrorCode.cs | Extends error-code IDs used by new shutdown/release logging. |
| src/Azure/Orleans.Streaming.AzureStorage/Storage/AzureQueueDataManager.cs | Adds IAzureQueueDataManager and implements ReleaseQueueMessage via UpdateMessageAsync(..., TimeSpan.Zero, ...). |
| src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/AzureQueueAdapterReceiver.cs | Adds operation tracking and shutdown-time release of pending receipts; retains pending receipts until deletion confirms. |
| src/Azure/Orleans.Streaming.AzureStorage/Orleans.Streaming.AzureStorage.csproj | Adds InternalsVisibleTo for Orleans.Azure.Tests to enable internal test seams. |
| docs/site/src/content/docs/implementation/streams-implementation/azure-queue-streams.md | Documents graceful handoff behavior and the Azure Queue “Update Message” permission requirement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage
Report-only conclusion: regressed. The current-main baseline is commit Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It changes core receiver shutdown/acknowledgement behavior with concurrent operation tracking and message visibility updates, warranting final human validation despite the added tests.
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/AzureQueueAdapterReceiver.cs — The shutdown-path receive bookkeeping removes duplicates by scanning pending once per newly… |
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/AzureQueueAdapterReceiver.cs — When shutdown begins during a receive, this branch clears pendingDeliveries, which later triggers… View resolved comment |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It changes shutdown/concurrency semantics in a production streaming receiver and relies on nuanced timing/cancellation behavior which warrants final human review despite the added tests.
Review tier: Lite
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/AzureQueueAdapterReceiver.cs — The shutdown-path receive bookkeeping removes duplicates by scanning pending once per newly… View comment |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Delivered-message deletion can partially succeed but still leave successfully deleted items in the pending set, causing incorrect pending bookkeeping and unnecessary shutdown release attempts/logging.
Review tier: Lite
Findings: None
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/AzureQueueAdapterReceiver.cs — The shutdown-path receive bookkeeping removes duplicates by scanning pending once per newly… View resolved comment |
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/AzureQueueAdapterReceiver.cs:298
ConfirmMessagesDeliveredAsyncusesTask.WhenAll(...)and only removes items frompendingafter all deletes succeed. If one delete throws, successfully deleted messages remain inpending, causing unnecessary later release attempts/logging and preventing the receiver from accurately reflecting confirmed acknowledgements. Consider deleting each message independently, removing successfully deleted items frompending, and rethrowing an aggregate for the failures.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new tests include an obsolete API call which can fail builds under warnings-as-errors and an order-dependent assertion which can introduce test flakiness.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 1
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
test/Extensions/Orleans.Azure.Tests/Streaming/AzureQueueAdapterTests.cs — This test calls the obsolete IQueueAdapterFactory.CreateAdapter() overload, which will raise… |
|
test/Extensions/Orleans.Azure.Tests/Streaming/AzureQueueAdapterReceiverTests.cs — This assertion depends on a specific ordering of queue.DeletedMessages/queue.ReleasedMessages,… |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It changes shutdown/handoff semantics in a distributed streaming receiver (including concurrent operation tracking and message visibility updates), which has significant reliability implications that warrant final human validation.
Review tier: Lite
Findings: None
Issues resolved since last review (2)
| Severity | Finding |
|---|---|
test/Extensions/Orleans.Azure.Tests/Streaming/AzureQueueAdapterReceiverTests.cs — This assertion depends on a specific ordering of queue.DeletedMessages/queue.ReleasedMessages,… View resolved comment |
|
test/Extensions/Orleans.Azure.Tests/Streaming/AzureQueueAdapterTests.cs — This test calls the obsolete IQueueAdapterFactory.CreateAdapter() overload, which will raise… View resolved comment |


Fixes #11119.
Problem
When Azure Queue ownership moves to another silo, the previous receiver can shut down with prefetched, unacknowledged messages still hidden by their visibility timeout. The replacement pulling agent cannot receive those messages until the lease expires, which caused the multi-stream join test to observe 9 of 10 deliveries for its full 30-second deadline.
Solution
Update Messagepermission requirement.Rationale
Graceful ownership transfer preserves at-least-once delivery while making unconfirmed work immediately available to the replacement receiver. Azure's existing visibility lease remains the recovery path for process failure or authorization/transport errors during release.
Microsoft Reviewers: Open in CodeFlow