[Backgroundrb-devel] Too many clients already

hemant gethemant at gmail.com
Wed Jun 25 22:35:05 EDT 2008

On Thu, Jun 26, 2008 at 3:03 AM, Dan Herrera <dan at revelationglobal.com> wrote:
> Greetings,
> We are currently working on offloading some long running tasks to
> backgroundrb, and we are using the thread_pool.defer method.  Our
> intent originally was to have one worker running, and have it process
> requests as they came in in threads, so that we don't have a lot of
> these workers running concurrently.
> It seems in our testing that backgroundrb is not closing these worker
> threads as they finish, and will eventually stop queueing new requests
> with the message:  FATAL:  sorry, too many clients already.
> Since we intend to open just one worker, and have it queue and process
> requests as they come in inside the thread pool, how do we close these
> threads once we are finished?  Or am I misunderstanding how this model
> should work, and we should be instantiating a new worker per request?
> Here is the code we are using:
> http://pastie.org/private/jnyues8lwlhvoqbmqd8w

Those worker threads are always active in thread pool ( or rather
waiting for new tasks in queue object, enqueued via #defer method) and
hence there is no point in stopping them, once they are done, since if
no work is there in queue, they will anyways sleep.

On which line you are getting the error? Can you paste full exception?
Could be some issue with Queue class.

More information about the Backgroundrb-devel mailing list