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

Threads remain in parked (waiting) state indefinitely when AblyRest instance is freed #801

Closed
QuintinWillison opened this issue Jun 20, 2022 · 1 comment · Fixed by #807
Assignees
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@QuintinWillison
Copy link
Contributor

QuintinWillison commented Jun 20, 2022

We've had a report from a customer:

we have noticed that when an instance of the AblyRest is replaced by another instance (as part of regenerating the client), the threads held by the old instance is not getting released or destroyed. This causes the threads to keep increasing as new instances of AblyRest gets created.

The threads are managed by the ThreadpoolExecutor in the AsyncHttpScheduler and a max of 64 (default) can get created. They are placed in parked (waiting) state indefinitely. These threads continue to remain in this state even after the AblyRest instance in which they belong to is removed.

It seems the AsyncHttpScheduler.dispose method is not getting called in this case.

This is causing the jvm memory usage to slowly increase over time.

┆Issue is synchronized with this Jira Bug by Unito

@QuintinWillison QuintinWillison added the bug Something isn't working. It's clear that this does need to be fixed. label Jun 20, 2022
@paddybyers
Copy link
Member

I think the issue is simply that the REST library doesn't have a lifecycle in the way that realtime does. You create the library, and you don't dispose the library, which would ordinarily dispose of resources. So either I think we need to make that lifecycle explicit (which I would prefer to avoid for the REST client) or have idle threads eventually exit so all resources are released without explicit action.

@paddybyers paddybyers changed the title Threads remain in parked (waiting) state indefinitely when AblyRest instance is free'd Threads remain in parked (waiting) state indefinitely when AblyRest instance is freed Jun 20, 2022
@QuintinWillison QuintinWillison self-assigned this Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

Successfully merging a pull request may close this issue.

2 participants