Skip to content
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

Merged
merged 7 commits into from
Aug 6, 2021

Conversation

JoshLove-msft
Copy link
Member

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.

@ghost ghost added the Service Bus label Aug 5, 2021
@@ -348,15 +355,15 @@ private async Task RenewSessionLock()
TaskContinuationOptions.ExecuteSynchronously,
TaskScheduler.Default)
.ConfigureAwait(false);
if (Receiver.IsClosed || delayTask.IsCanceled)
Copy link
Member Author

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.

@JoshLove-msft
Copy link
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -287,7 +295,7 @@ public override async Task ReceiveAndProcessMessagesAsync(CancellationToken proc
}
}
catch (Exception ex)
when (!(ex is TaskCanceledException) ||
when (ex is not TaskCanceledException ||
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoshLove-msft
Copy link
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft
Copy link
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link

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();
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It made Rider happy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@JoshLove-msft
Copy link
Member Author

/azp run net - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft JoshLove-msft enabled auto-merge (squash) August 6, 2021 04:41
@JoshLove-msft JoshLove-msft merged commit 89866f9 into Azure:main Aug 6, 2021
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-net that referenced this pull request Apr 14, 2023
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants