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
Actors/Threads remain after calling SupervisionGroup#finalize and terminate #203
Comments
To add some more context, my actual app dynamically generates supervisor names to focus workers on a specific queue. So I run 100 different jobs, there are 100 different supervisor keys generated. Their worker pools get shut down, but those internal "RubyThread" never exit and the result is a lot of threads continue to run until I run out of memory. This happened on Heroku as well. According to VisualVM, the "RubyThread"s are coming from /Users/admin/.rvm/gems/jruby-1.7.2/gems/celluloid-0.12.4/lib/celluloid/internal_pool.rb:45. |
On Fri, Mar 29, 2013 at 8:59 AM, Marty McKenna notifications@github.comwrote:
Tony Arcieri |
It happens locally with 1 supervisor as well. Those "RubyThreads" never go away. If I launch 2 supervisors, its the same deal. Is that expected behavior? edit: I mentioned my app on Heroku because you would never notice a problem if it was just one supervisor, because the same threads get reused. But I would assume the threads should still exit when the supervisor is finalized or terminated, right? |
Celluloid uses a thread pool, and the threads of terminated actors remain On Fri, Mar 29, 2013 at 9:51 AM, Marty McKenna notifications@github.comwrote:
Tony Arcieri |
Is there a way to kill all of the threads and/or thread pool spawned by the supervisor when terminating it? |
I've updated my example (https://gist.github.com/martyMM/5271674). If I start a regular pool without a supervisor, the thread counts add up when the pool is terminated. If I start a pool, terminate it, then start an actor, the thread counts also add up. The thread counts do not add up when creating a pool with a supervisor. Also, when running the try_pool_and_actor multiple times, the thread counts zero out at first, but eventually become +1 as well as increasing by 1 for each call and never go down: https://gist.github.com/martyMM/5273334 |
Here's Celluloid's internal thread pool: https://github.com/celluloid/celluloid/blob/master/lib/celluloid/internal_pool.rb You can disable it with:
On Fri, Mar 29, 2013 at 1:17 PM, Marty McKenna notifications@github.comwrote:
Tony Arcieri |
What you should confirm... either:
On Fri, Mar 29, 2013 at 2:05 PM, Tony Arcieri tony.arcieri@gmail.comwrote:
Tony Arcieri |
This particular issue was with 2) Threads persist with the pool disabled |
Can you post a |
@martyMM could you please also update the gist with a reproduction which produces these leaked Threads directly? |
I am able to reproduce this issue on jruby 1.7.2 and 1.7.4-dev.
jruby
MRI
|
One interesting thing to note is that the Also, there is an issue with finalizers where they can be terminated prematurely. |
I think this is a point of confusion rather than being a bug with Celluloid. |
Fiber thread pool would definitely be another explanation |
That is the issue here. I reopened your bug with @jruby... |
Running into a problem where threads are remaining after their SupervisionGroup has been terminated. You can reproduce it by grabbing the script below, launching a console and requiring the file. See my output below. Also notice the error when calling Celluloid.stack_dump immediately after completion. However, waiting a few minutes will let stack_dump run successfully.
Tested on JRuby 1.7.2
Script: https://gist.github.com/martyMM/5271674
open IRB and require the file
What is also interesting is that when watching with VisualVM, all of the JRubyWorker threads exit after a while (presumably these are the pool workers that were launched), but a lot of RubyThreads remain until I kill the console process.
The text was updated successfully, but these errors were encountered: