-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure SessionReceiverManager is cleaned up when closing #23121
Conversation
@@ -348,15 +355,15 @@ private async Task RenewSessionLock() | |||
TaskContinuationOptions.ExecuteSynchronously, | |||
TaskScheduler.Default) | |||
.ConfigureAwait(false); | |||
if (Receiver.IsClosed || delayTask.IsCanceled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be necessary as we await the RenewSessionLock task before calling Dispose on the receiver.
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
sdk/servicebus/Azure.Messaging.ServiceBus/src/Processor/SessionReceiverManager.cs
Show resolved
Hide resolved
@@ -287,7 +295,7 @@ public override async Task ReceiveAndProcessMessagesAsync(CancellationToken proc | |||
} | |||
} | |||
catch (Exception ex) | |||
when (!(ex is TaskCanceledException) || | |||
when (ex is not TaskCanceledException || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this flow difficult to read. It took me a few passes to pick up on 299-301 still being part of the where
.
{ | ||
break; | ||
} | ||
await _receiver.RenewSessionLockAsync(sessionLockRenewalCancellationToken).ConfigureAwait(false); | ||
ServiceBusEventSource.Log.ProcessorRenewSessionLockComplete(Processor.Identifier); | ||
} | ||
|
||
catch (Exception ex) when (!(ex is TaskCanceledException)) | ||
catch (Exception ex) when (ex is not TaskCanceledException) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -980,6 +981,7 @@ private void WakeLoop() | |||
// wake up the handler loop | |||
var handlerCts = Interlocked.Exchange(ref _handlerCts, new CancellationTokenSource()); | |||
handlerCts.Cancel(); | |||
handlerCts.Dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 78% certain you don't need to dispose after cancel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It made Rider happy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
/azp run net - servicebus - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
Release sentinel 2023 04 01 preview (Azure#23121) * Adds base for updating Microsoft.SecurityInsights from version preview/2023-03-01-preview to version 2023-04-01-preview * Updates readme * Updates API version in new specs and examples * Workspace Manager Members (Azure#23134) * Adds base for updating Microsoft.SecurityInsights from version preview/2023-02-01-preview to version 2023-04-01-preview * Updates readme * Updates API version in new specs and examples * Workspace Manager Members * udpate pattern * Workspace manager configurations (Azure#23133) * Adds base for updating Microsoft.SecurityInsights from version preview/2023-02-01-preview to version 2023-04-01-preview * Updates readme * Updates API version in new specs and examples * adding april configurations swagger * update pattern * prettier update * update readme * Workspace manager assignments (Azure#23130) * Adds base for updating Microsoft.SecurityInsights from version preview/2023-02-01-preview to version 2023-04-01-preview * Updates readme * Updates API version in new specs and examples * Workspace Manager Assignments/Jobs * update readme * updated from comments * update from lint diff errors * updated descriptions * Workspace manager groups (Azure#23135) * Adds base for updating Microsoft.SecurityInsights from version preview/2023-02-01-preview to version 2023-04-01-preview * Updates readme * Updates API version in new specs and examples * april swagger for groups * update path name & pattern * [Hunts] Add hunts to Sentinel 2023-04-01-preview version (Azure#23139) * Add hunts files * Include update in 200 description and add defaults * Add back 201 * Update relation properties * Update example --------- Co-authored-by: Derrick Lee <derricklee@microsoft.com> * Add readonly flag to providerName property (Azure#23259) * sentinel content hub package and template API (Azure#23151) * commit for content template and content package API * fix issues reported by swagger lint * add 201 for put requests in template service * resolve the comments * resolve comments in packageId * resolve comments * update descriptions due to lint error (Azure#23392) * Fix policheck issue by updating the description. (Azure#23415) * Fix polich issue by updating the description. * update the description to fix a typo. * Release sentinel 2023 04 01 preview (Azure#23420) * Fix polich issue by updating the description. * update the description to fix a typo. * fix policheck by updating description * rename enum name to stable version to fix cross-version breaking change failure. * fix typo (Azure#23463) --------- Co-authored-by: rheabansal <93624991+rheabansal@users.noreply.github.com> Co-authored-by: Derrick Lee <derricklee91@gmail.com> Co-authored-by: Derrick Lee <derricklee@microsoft.com> Co-authored-by: Anat Gilenson <53407600+anat-gilenson@users.noreply.github.com> Co-authored-by: xuhumsft <116764429+xuhumsft@users.noreply.github.com> Co-authored-by: Nan Zang <nazang@microsoft.com>
While investigating #23065, I noticed that there is a case where _receiver may not be reset to null even after we attempt to Dispose it, this could lead to a new session never getting accepted. I don't think it would lead to the behavior from the issue, as we should still be exiting the receive loop once we have a sessionLockLost error.