-
Notifications
You must be signed in to change notification settings - Fork 59
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
Getting "ReactorDispatcher instance is closed" error when trying to close the azure service bus connection after receiving message #418
Comments
@Rawjyot, thanks for sharing the observation. We have already noticed via many git-issues that this log message with the "error" level is misleading users. The level of this log message changed to"warning" in 7.4.2 (in Oct release). There are multiple threads running in parallel; hence it's possible that when the connection close is in progress, another thread may attempt to "dispatch" work to this connection, those attempts will be dropped with this "warning". |
@anuchandy the problem we're having is that after receiving this warning message subsequent attempts to retrieve a message with a new ServiceBusReceiverClient will fail for several minutes and generate the same error message. Eventually an attempt is successful but, after polling a few times we get the same error again when calling close(). You mentioned the library had multiple threads running in parallel. When our code is closing and destroying a ServiceBusReceiverClient instance and then shortly creating a new instance could we be instead getting the same instance that was previously closed but for some reason not destroyed? Could the ServiceBusClientBuilder factory be reusing an already closed instance? This behavior is not seen using the older 7.1.0 version of azure-messaging-servicebus. |
I see; yes Jim, ServiceBusClientBuilder shares a few resources among the clients built from it. It is possible that after the closing of the first client but before the completion of underlying async resources cleanup, a newing up of the second client might be getting the endpoint from the cache. Due to the async cleanup/notification, it takes some time for the second client to detect it. Can you unblock for now by using a new builder ? |
@anuchandy the code is using a new ServiceClientBuilder every time: receiver = new ServiceBusClientBuilder() IterableStream messages = receiver.receiveMessages(1, Duration.ofSeconds(5)); // Examine and act on any message if (message != null) { |
Hi @lordarcy, I tried to repro the behavior using the code below, where we can see "create-client, receive-message, and close-client" in a loop (10 times). import java.time.Duration;
import java.time.OffsetDateTime;
import com.azure.messaging.servicebus.ServiceBusClientBuilder;
import com.azure.messaging.servicebus.ServiceBusReceiverClient;
import com.azure.messaging.servicebus.ServiceBusReceivedMessage;
public class ReceiveCloseLoopSample {
public static void main(String[] args) {
final String connectionString = System.getenv("CON_STR");
final String queueName = System.getenv("QUEUE_NAME");
// Loop for 10 times.
for (int i = 0; i < 10; i++) {
System.out.println(OffsetDateTime.now() + ": Creating Client#" + i);
ServiceBusReceiverClient receiver = new ServiceBusClientBuilder()
.connectionString(connectionString)
.receiver()
.disableAutoComplete()
.queueName(queueName)
.buildClient();
IterableStream<ServiceBusReceivedMessage> messages = receiver.receiveMessages(1, Duration.ofSeconds(5));
messages.forEach(message -> {
System.out.println(OffsetDateTime.now() + ": Received Message [seq_number:" + message.getSequenceNumber() + "]");
if (message != null) {
try {
receiver.complete(message);
} catch (Throwable t) {
t.printStackTrace();
}
System.out.println(OffsetDateTime.now() + ": complete call finished for Message [seq_number:" + message.getSequenceNumber() + "]");
}
});
System.out.println(OffsetDateTime.now() + ": Closing Client#" + i);
receiver.close();
System.out.println("");
}
}
} But I don't see the issue you mentioned happening, the output of the execution looks like this
Could you please double check my code and also see if this is how your application is attempting to use the client. |
I see three main differences:
|
Thanks, I'm trying to map your points back to code - so you have a concept known as "polling transaction." Each time the "polling transaction" executes, it "create-client instance, receive a message, and close-client instance", meaning there is a 1:1 relationship between a client instance and an execution of "polling transaction". Isn't the sample code I posted doing, where one iteration of the loop corresponds to one execution of "polling transaction."? The part missing in the my sample code is - If we find that no message was received, then the code should create a receiver client for DLQ then attempt to receive a message from it? Is this understanding correct? |
The two things missing from your sample are:
|
@lordarcy Sorry for the late follow-up, Is it possible for your team to update the code I shared so far to match the way you are using the library, so that this can be reproduced on our end? I've pushed the code to git we've been discussing above to here https://github.com/anuchandy/attempt-repro-polling-bug. It can be cloned, ready to run once you set the connection string and queue in the env vars. You and Rowjyot have access to the git. |
@Rawjyot is this something you can try? |
Yes sure I will give it a try
…On Sat, 11 Dec, 2021, 2:03 am Jim Robbins, ***@***.***> wrote:
@Rawjyot <https://github.com/Rawjyot> is this something you can try?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#418 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEO3U2VDN4UGH7MRPJDR663UQJPZ7ANCNFSM5GAQRLLA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
@Rawjyot have you had a chance to try updating the code sample with the library to try and reproduce the problem? |
@anuchandy can you please provide me access to https://github.com/anuchandy/attempt-repro-polling-bug again? I tried accessing it and it says the invitation has expired. |
@anuchandy I don't have access to the above private repository you shared, meanwhile, @lordarcy shared the code base with zip. I have gone through the codebase, here are a few observations.
I will try to replicate these parameters and provide you with updated code. cc: @lordarcy |
Actual Behavior
Expected Behavior
I am using:
Versions
The text was updated successfully, but these errors were encountered: