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

Producer DisposeAsync blocks indefinitely when no longer connected #270

Open
chriscameron-vertexinc opened this issue Jul 31, 2024 · 1 comment

Comments

@chriscameron-vertexinc
Copy link
Contributor

chriscameron-vertexinc commented Jul 31, 2024

Hello!

I've identified a problem in my application where when I try to dispose disconnected producers my thread will block forever.

Whenever I attempt to publish a message I first lazy load a producer. I have code that looks something like:

// Is the existing producer good?
if (await producer.IsConnected())
    return producer;

// Dispose the dead producer
await producer.DisposeAsync();

// Create a new producer
return await CreateProducerAsync();

I'm running the official Pulsar Docker image and successfully publishing messages to it. If I restart the container, breaking the connection, my application will hit the DisposeAsync() and block forever.

Looking at the dispose method for ProducerImpl it looks like it doesn't really do anything if the connection state is closed. https://github.com/fsprojects/pulsar-client-dotnet/blob/develop/src/Pulsar.Client/Internal/ProducerImpl.fs#L935

As a workaround I'm simply not disposing my producers if they're no longer connected anymore. Is this safe?

@Lanayx
Copy link
Member

Lanayx commented Jul 31, 2024

First of all, .IsConnected() is just for informational purpose, you shouldn't dispose producer based on that, since it can be in Connecting state. As for blocking forever, I've published https://www.nuget.org/packages/Pulsar.Client/3.5.3 to fix a related issue, it might help you as well. If not, can you please provide more details and debug logs (good example)

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

No branches or pull requests

2 participants