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

[azservicebus] Fixing bug where cancelling link creation could leak resources #18479

Conversation

richardpark-msft
Copy link
Member

@richardpark-msft richardpark-msft commented Jun 24, 2022

Attempting to shoe-horn the draining of the channel into the same goroutine doesn't work - it leads to a potential race condition or can lead to a blocking condition identified by @franklinkim in #18477.

The simplest fix is just to treat the original goroutine as a cancellable function call and then handle the return value logic inside of the main func instead. This ensures we always drain the 'done' channel, even if we decide to cancel early.

NOTE, this also unearthed a bug where we were sometimes passing (amqp., nil) instead of (, nil) in the amqp wrappers. This was fixed, along with the spot that was unintentionally using it even when there was an error.

@richardpark-msft
Copy link
Member Author

/azp run go - azservicebus

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft
Copy link
Member Author

/azp run go - azservicebus

@richardpark-msft
Copy link
Member Author

(condition was inverted, fixing)

@richardpark-msft
Copy link
Member Author

/azp run go - azservicebus

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1. When the amqpwrap code is returning a concrete object as part of the return value and it's being "converted" into an interface we need to make sure we return the correct 'nil'.

2. The bigger bug: when amqpLinks was creating links it would assign the result of the function to it's internal field directly in the call. Since <interface>nil isn't the same as <concrete-type>nil it would look like there was a Receiver to close, even when there wasn't.
@richardpark-msft
Copy link
Member Author

/azp run go - azservicebus

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft
Copy link
Member Author

/azp run go - azservicebus

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft richardpark-msft merged commit 90ec5c9 into Azure:release/azservicebus/v1 Jun 27, 2022
@richardpark-msft richardpark-msft deleted the sb-fix-link-cancel branch June 27, 2022 17:47
@franklinkim
Copy link

@richardpark-msft thx, for quick fix

richardpark-msft pushed a commit to richardpark-msft/azure-sdk-for-go that referenced this pull request Jun 30, 2022
…f3cb

This go-amqp update lets us cancel links directly, rather than having to
do our workaround with the goroutines. It also swaps some of the core
types from using variadic config to using struct based config instead.

In addition, Updating with some changes from Azure#18479:
- Fixing bug where we were assigning non-functional entities to amqpLinks's fields
- Fixing a bug where I was doing the (interface, nil) instead of (nil, nil) for stuff
  coming back from amqpwrap!
richardpark-msft added a commit that referenced this pull request Jun 30, 2022
…a7e7511a069acc4f3cb (#18503)

This go-amqp update lets us cancel links directly, rather than having to
do our workaround with the goroutines. It also swaps some of the core
types from using variadic config to using struct based config instead.

In addition, Updating with some changes from #18479:
- Fixing bug where we were assigning non-functional entities to amqpLinks's fields
- Fixing a bug where I was doing the (interface, nil) instead of (nil, nil) for stuff
  coming back from amqpwrap!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants