Fix subscription recovery - #7541
Open
Vadim Kovalyov (vadim-kovalyov) wants to merge 2 commits into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Vadim Kovalyov (vadim-kovalyov)
requested review from
Damon Barry (damonbarry),
Varun Puranik (varunpuranik) and
vipeller
and
a balanced review from Copilot
August 28, 2026 00:22
Copilot started reviewing on behalf of
Vadim Kovalyov (vadim-kovalyov)
September 2, 2026 19:24
View session
There was a problem hiding this comment.
🟡 Changes recommended
Cloud-proxy creation can remain pending after disposal because its lookup does not observe shutdown cancellation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes subscription recovery when cloud proxies are temporarily unavailable.
Changes:
- Adds per-client retries, bounded backoff, and replay coalescing.
- Preserves pending subscription ordering.
- Cancels recovery work during shutdown and expands test coverage.
File summaries
| File | Review |
|---|---|
edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Core.Test/SubscriptionProcessorTest.cs |
Adds recovery, ordering, isolation, concurrency, and disposal tests. |
edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Core.Test/routing/RoutingEdgeHubTest.cs |
Verifies subscription processor disposal. |
edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs |
Disposes Edge Hub during shutdown. |
edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/SubscriptionProcessor.cs |
Implements recovery and retry logic. Cloud-proxy lookup must observe shutdown cancellation; timeout messaging should describe scheduled retries. |
edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/routing/RoutingEdgeHub.cs |
Disposes the subscription processor. |
Review details
Suppressed comments (1)
edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/SubscriptionProcessor.cs:363
- This timeout is now retried automatically by
ProcessSubscriptionsAsyncafter a backoff, not only when the client reconnects. The current message gives operators an incorrect recovery condition; describe the scheduled retry instead.
Log.LogDebug((int)EventIds.ErrorProcessingSubscriptions, ex, Invariant($"Timed out while processing subscriptions for client {id}. Will try again when connected."));
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| bool retry; | ||
| try | ||
| { | ||
| Option<ICloudProxy> cloudProxy = await this.ConnectionManager.GetCloudConnection(id); |
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
SubscriptionProcessor.ProcessPendingSubscriptions()currently drains a client's pendingsubscription queue even when
ConnectionManager.GetCloudConnection(id)returnsOption.None<ICloudProxy>.Each dequeued operation is passed to
ProcessSubscriptionWithRetry(). For subscriptions thatneed a cloud proxy,
ProcessSubscription()usesOption.ForEach()orOption.ForEachAsync(). WithOption.None, these calls complete without invoking the cloudoperation and without throwing. The retry policy therefore treats the operation as successful,
while the pending operation has already been removed.
Fix
Tests covererage for missing and failed proxy creation, subscription ordering, client isolation, retry coalescing, overlapping replay, and disposal.