Skip to content

Singleton (and FaultTolerantAmqpObject) Does not Correctly Handle Concurrent Opening & Closing #172

@paulsavides

Description

@paulsavides

Reproduction Repro
Please view reproduction here >> https://github.com/paulsavides/ServiceBusTesting/blob/4cf80ba2f8e2d725b2d1923600d4aba3f26ee9b3/InterestingTests/SingletonTests.cs#L12-L38

Overview
When using the singleton class, running GetOrCreateAsync() & CloseAsync() in a particular order, the singleton will end up disposed but with Value remaining populated.

This doesn't technically violate the "Singleton-ness" of the class, but it introduces the same error to FaultTolerantAmqpObject. If you were to setup code like...

var creating = _faultTolerantLink.GetOrCreateAsync(Timeout);
await _faultTolerantLink.CloseAsync();

var link = await creating;

There is a possibility that you now have an active link in a 'Closed' amqpobject. The above code is, of course, a simplified example, but in more complex code its possible the area that is receiving messages & running the receive link is not aware of the area that is responsible for closing the link. So, it would be more forgivable to have the following sequence running.

I am opening this issue largely because I believe I am running into the issue in the Microsoft.Azure.ServiceBus library Azure/azure-sdk-for-net#16994


Please let me know if you require any clarification.

Thank you for taking the time to look at this issue,
Paul Savides

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions