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

[BUG] Service Bus: Memory leak if session based consumer is closed and (re)started #18294

Closed
alewis001 opened this issue Dec 21, 2020 · 4 comments
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus

Comments

@alewis001
Copy link

Describe the bug
There is a memory leak is a session-based processor client is closed and then restarted.

Closing and restarting the processor client was done in an attempt to work around #18122. Closing and restarting does cause the SDK to pull the messages from the active sessions; however, this leak is causing the application to OutOfMemory.

Stopping I.e. stop() and restarting the client does not work as it does not retrieve the latest messages from a session as per #18122 so Closing is the only option whilst #18122 exists.

To Reproduce
Steps to reproduce the behavior:

  1. Create a session based processor, call start.
  2. After some time, call close().
  3. Call start on the processor.
  4. Goto 2.

E.g. see code snippet.

Code Snippet

ScheduledExecutorService es = Executors.newSingleThreadScheduledExecutor();
es.scheduleAtFixedRate(() -> {
    try {
        System.out.println("Restarting client");
        if (processorClient != null) {
            processorClient.close();
        } else {
            processorClient = buildClient();
        }
        processorClient.start();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}, 1, 30, TimeUnit.SECONDS);
private ServiceBusProcessorClient buildClient() {
        return new ServiceBusClientBuilder()
                .connectionString("<< connection string >>")
                .sessionProcessor()
                .queueName("<< queue >>")
                .maxConcurrentSessions(10)
                .processMessage(this::processMessage)
                .processError(this::processError)
                .buildProcessorClient();
    }

Expected behavior
No memory leak.

Setup (please complete the following information):

  • OS: MacOS
  • IDE : Netbeans
  • Version of the Library used: 7.0.0
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 21, 2020
@alzimmermsft alzimmermsft added Client This issue points to a problem in the data-plane of the library. Service Bus labels Dec 28, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 28, 2020
@hemanttanwar
Copy link
Contributor

@alewis001 We have released new version of library which has fix for #18122 , You can download it from here https://search.maven.org/artifact/com.azure/azure-messaging-servicebus
Can you try and let us know if you still see any issue ?

@alewis001
Copy link
Author

Thanks @hemanttanwar, I'll give it a try ASAP and let you know.

@alewis001
Copy link
Author

Hi @hemanttanwar, #18122 is fixed at least in my testing. Thank you again.

This specific issue about a memory leak when restarting the client is still present in 7.0.1; however, I can see how you may consider that lower priority as it's maybe an unusual thing to do to keep restarting the client every 30s. The important one for us was #18122 and that has been resolved now so we no longer need to do the restart loop.

Thanks again and pass my thanks on to the team.

@hemanttanwar
Copy link
Contributor

hemanttanwar commented Jan 21, 2021

@alewis001 I appreciate you working with our library.
Also If you feel like you can contribute to our library in terms of documentation, fixes etc, here is our contributing guide .
I will close this ticket now.

@ramya-rao-a ramya-rao-a added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Feb 22, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Projects
None yet
Development

No branches or pull requests

4 participants