# BJ - Reaping 1 threads for slow workers because of 'shutdown'

**URL:** <https://www.ruby-forum.com/t/bj-reaping-1-threads-for-slow-workers-because-of-shutdown/143916>\
**Category:** Ruby\
**Created:** [July 23, 2008, 8:50pm UTC](https://www.ruby-forum.com/t/bj-reaping-1-threads-for-slow-workers-because-of-shutdown/143916 "2008-07-23T20:50:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dusty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@dusty](https://www.ruby-forum.com/u/dusty)\
**Post date:** [July 23, 2008, 8:50pm UTC](https://www.ruby-forum.com/t/bj-reaping-1-threads-for-slow-workers-because-of-shutdown/143916/1 "2008-07-23T20:50:32Z")

</div>

I’m calling Bj from inside a controller in rails.

# controller code

[http://pastie.org/239415](http://pastie.org/239415)

Its running a simple script that logs the user to the database.  
Obviously this isn’t a good candidate for a background job, this is  
just something simple I’m using to test.

# bj script code

[http://pastie.org/239418](http://pastie.org/239418)

When I shutdown rails, I get a timeout error from mongrel

# log snippet

[http://pastie.org/239419](http://pastie.org/239419)

Any ideas why mongrel is holding on to that thread? I am calling  
exit\_success! at the end of my run action in the bj script, it appears  
the script is exiting properly.

I also find it strange that the sessions\_controller is referred to in  
that backtrace.

Any ideas?

Thanks  
dusty doris

---

<div class="post-metadata">

**Author:** ![dusty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@dusty](https://www.ruby-forum.com/u/dusty)\
**Post date:** [July 23, 2008, 9:46pm UTC](https://www.ruby-forum.com/t/bj-reaping-1-threads-for-slow-workers-because-of-shutdown/143916/2 "2008-07-23T21:46:47Z")

</div>

Here is an update. I tried in development vs production and that  
didn’t make a difference. However, I only saw this behavior on  
mongrel. On thin and webrick it would quit quickly.

---

<div class="post-metadata">

**Author:** ![dusty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@dusty](https://www.ruby-forum.com/u/dusty)\
**Post date:** [July 23, 2008, 10:10pm UTC](https://www.ruby-forum.com/t/bj-reaping-1-threads-for-slow-workers-because-of-shutdown/143916/3 "2008-07-23T22:10:54Z")

</div>

On Jul 23, 2008, at 1:39 PM, dusty wrote:

> Here is an update. I tried in development vs production and that  
> didn’t make a difference. However, I only saw this behavior on  
> mongrel. On thin and webrick it would quit quickly.

it’s a mongrel bug - mongrel tries to reap threads it does not own.  
nothing to do with bj and you can safely ignore.

a @ [http://codeforpeople.com/](http://codeforpeople.com/)

---

<div class="post-metadata">

**Author:** ![dusty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@dusty](https://www.ruby-forum.com/u/dusty)\
**Post date:** [July 23, 2008, 10:37pm UTC](https://www.ruby-forum.com/t/bj-reaping-1-threads-for-slow-workers-because-of-shutdown/143916/4 "2008-07-23T22:37:22Z")

</div>

Great. Thanks.

BTW - I’m having fun with Bj. Thanks for writing it!

-Dusty

---

<div class="post-metadata">

**Author:** ![dusty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@dusty](https://www.ruby-forum.com/u/dusty)\
**Post date:** [August 26, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/bj-reaping-1-threads-for-slow-workers-because-of-shutdown/143916/5 "2008-08-26T23:55:42Z")

</div>

> it’s a mongrel bug - mongrel tries to reap threads it does not own.  
> nothing to do with bj and you can safely ignore.

But what’s the solution to it delaying the shutdown of mongrel?

---

<div class="post-metadata">

**Author:** ![dusty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@dusty](https://www.ruby-forum.com/u/dusty)\
**Post date:** [August 27, 2008, 12:31am UTC](https://www.ruby-forum.com/t/bj-reaping-1-threads-for-slow-workers-because-of-shutdown/143916/6 "2008-08-27T00:31:25Z")

</div>

On Aug 26, 2008, at 3:50 PM, fowlduck wrote:

> But what’s the solution to it delaying the shutdown of mongrel?

patch mongrel.

bj doesn’t delay the shutdown - it merely creates a thread which  
mongrel insists on reaping. the fix is for mongrel not to reap  
threads it hasn’t started.

a @ [http://codeforpeople.com/](http://codeforpeople.com/)
