reset pending orchestrations when worker restart#1358
Open
kaibocai wants to merge 1 commit into
Open
Conversation
Comment on lines
+246
to
+254
| catch (Exception e) | ||
| { | ||
| this.settings.Logger.PartitionManagerWarning( | ||
| this.storageAccountName, | ||
| this.settings.TaskHubName, | ||
| this.settings.WorkerId, | ||
| this.Name, | ||
| $"Failed to abandon message {queueMessage.MessageId} during drain: {e.Message}"); | ||
| } |
Comment on lines
+259
to
+261
| catch (OperationCanceledException) | ||
| { | ||
| } |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Azure Storage partition drain behavior by ensuring control-queue messages that were dequeued but not yet dispatched are re-exposed immediately when a partition is released, avoiding a throughput gap during lease transitions.
Changes:
- Abandon pending (dequeued-but-undispatched) control-queue messages with zero visibility timeout during
DrainAsync. - Guard
GetNextSessionAsyncagainst ready-queue nodes that were drained/removed from the pending list. - Add a unit test intended to validate skipping of drained ready-queue nodes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/DurableTask.AzureStorage/OrchestrationSessionManager.cs |
Abandons pending message batches during drain and skips drained nodes during session dequeue. |
src/DurableTask.AzureStorage/Messaging/ControlQueue.cs |
Adds a drain-specific abandon path that updates message visibility timeout to zero. |
Test/DurableTask.AzureStorage.Tests/OrchestrationSessionTests.cs |
Adds a test for drained ready-queue node handling (but currently under an inactive test directory). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+228
to
+235
| [TestMethod] | ||
| public async Task GetNextSessionAsync_DrainedReadyQueueNode_IsIgnored() | ||
| { | ||
| var settings = new AzureStorageOrchestrationServiceSettings | ||
| { | ||
| StorageAccountClientProvider = new StorageAccountClientProvider("UseDevelopmentStorage=true"), | ||
| }; | ||
| var stats = new AzureStorageOrchestrationServiceStats(); |
Comment on lines
+253
to
+261
| using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(100)); | ||
| try | ||
| { | ||
| await manager.GetNextSessionAsync(entitiesOnly: false, cts.Token); | ||
| Assert.Fail("Expected cancellation after the drained node was skipped."); | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| } |
| { | ||
| // Remove the partition from memory | ||
| // Make dequeued-but-undispatched messages visible before dropping the partition. | ||
| await this.AbandonPendingMessagesAsync(partitionId); |
| this.settings.TaskHubName, | ||
| this.settings.WorkerId, | ||
| this.Name, | ||
| $"Failed to abandon message {queueMessage.MessageId} during drain: {e.Message}"); |
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.
This PR improves partition drain behavior for Azure Storage control queues. When a partition is released, any control queue messages that were already dequeued but not yet dispatched to an active orchestration session are now abandoned with zero visibility timeout, making them immediately visible for the next partition owner.
The change prevents a throughput gap during lease transitions where pending in-memory messages could otherwise remain invisible until their original visibility timeout expired.
Related ICM: https://portal.microsofticm.com/imp/v5/incidents/details/21000001021644/summary