Skip to content

ScheduledDataLoaderRegistry can leak scheduler threads #137

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

Closed
DanielThomas opened this issue Nov 12, 2023 · 1 comment
Closed

ScheduledDataLoaderRegistry can leak scheduler threads #137

DanielThomas opened this issue Nov 12, 2023 · 1 comment

Comments

@DanielThomas
Copy link

Related to #135, I noticed that the executor isn't shut down, so if it's used, would leak the single core thread.

Since JDK 9 the default keepalive timeout is 10ms, so allowCoreThreadTimeOut is a potential solution, if you want to avoid explicit shutdown() in close():

https://github.com/openjdk/jdk/blob/caf71810f85ea55083ce7d1c76307a0c42d9be0e/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java#L429-L443

Incidentally, folks on JDK 21 using JSON thread dumps should watch for this, because it's tricky to troubleshoot:

  • On JDK 21 ThreadPoolExecutors register as ThreadContainers, a concept added to support thread dumps with virtual threads
  • We happen have a periodic thread dump script, which takes JSON thread dumps
  • TheadContainers#children doesn't scale well, on my machine with 30K containers (2m of runtime @ 250 rps) ThreadDumper takes a minute
  • On a real application instance, that caused ThreadDumper to run indefinitely, because the application outpaces the ThreadDumper's ability to walk thread containers
  • ThreadDumper also dutifully collects the ThreadContainers onto a list, which caused the weak references to the containers to live forever, causing a memory leak
@bbakerman
Copy link
Member

#144 addresses this

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