Paul O'Leary wrote:
> 
> [snip]
> 
> Yes, I'm sure.  In fact, I'm never even given a chance to return the
> connections.  My problem is that I allocate a whole bunch of threads at
> once and that each immediately requests a connection from the pool.
> Unfortunately, I have more threads than the integer value of
> database.maxConnections is set to, so the pool was getting stuck in a
> wait state (waiting for connections to be released).  It was waiting
> indefinitely, however, as my new threads were still trying to request
> connections.  As soon as I bumped database.maxConnections to a number
> higher than I had threads, I stopped hitting the wait state.
> 
> [snip]
> 
> hmmm.  the way you describe this suggests there maybe something else going
> on.  if you have N connections and N+1 threads, then the first N threads
> should be able to get connections.  the last thread will hit the wait state
> but that shouldn't mean that the other N threads should be blocked and
> prevented from eventually returning their connections and waking up the
> sleeping thread.
> 
> *unless* there's some problems I'm not seeing...

I missed an important bit of information here.  All the threads are
allocated at once.  As each thread is constructed, it requests a
connection from the pool.  The threads do not actually have start()
called on them--to set them of and running--until after they've *all*
been allocated.  The threads don't release their connections until
they've reached the end of their run() method, or are interrupt()'d. 
Thus, more connections are allocated up front than allowed by the pool
configuration, sending the connection pool into a wait state.

In retrospect, perhaps I need to modify the way I am allocating thread
resources, or allocating threads?  I'm not sure which is the Right
Thing--I'll think about it.  Anyways, the pool should still probably not
just lock up the entire application because I tried to allocate too many
connections at once.
-- 

Daniel Rall <[EMAIL PROTECTED]>


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to