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

Disposing Connection after closing it with timeout causes deadlock #1759

Open
lukebakken opened this issue Jan 6, 2025 Discussed in #1758 · 4 comments
Open

Disposing Connection after closing it with timeout causes deadlock #1759

lukebakken opened this issue Jan 6, 2025 Discussed in #1758 · 4 comments
Assignees
Labels
Milestone

Comments

@lukebakken
Copy link
Contributor

Discussed in #1758

Originally posted by JanEggers January 6, 2025

Describe the bug

[TestMethod]
public async Task DisposeWhileCatchingTimeoutDeadlocksRepro()
{
    var factory = new ConnectionFactory
    {
        UserName = "rabbit",
        Password = "rabbit",
        HostName = "localhost",
        VirtualHost = "/",
        AutomaticRecoveryEnabled = true
    };

    var receiveConnection = await factory.CreateConnectionAsync();
    try
    {
        await receiveConnection.CloseAsync(TimeSpan.Zero);
    }
    catch (Exception e)
    {
    }

    // this blocks forever
    await receiveConnection.DisposeAsync();
}

Reproduction steps

see code

Expected behavior

Dispose should never block it must either throw or work

Additional context

Im currently migrating to version from 6.8.1 to 7.0 but this causes my tests to be stuck.

@lukebakken lukebakken added the bug label Jan 6, 2025
@lukebakken lukebakken added this to the 7.1.0 milestone Jan 6, 2025
@lukebakken lukebakken self-assigned this Jan 6, 2025
@lukebakken
Copy link
Contributor Author

Hi @JanEggers, thanks for providing the code to reproduce the issue. You've probably found a bug, or a change in behavior around TimeSpan.Zero.

What is the intent of using TimeSpan.Zero in your code/tests? Do you intend it to mean "infinite timeout"?

@JanEggers
Copy link
Contributor

The intend is aborting the connection and cleaning up the resources used during testing, similar code would also run while our app is shutting down.

So any guidance on what do instead would be apprecheated

btw thx for the quick response :)

@JanEggers
Copy link
Contributor

think I found it myself using AbortAsync() instead of CloseAsync(TimeSpan.Zero) gives the expected behavior

@JanEggers
Copy link
Contributor

AbortAsync(TimeSpan.Zero) seems to have the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants