Mantis - Resin
Viewing Issue Advanced Details
3837 minor always 01-05-10 15:00 01-07-10 10:00
alex  
ferg  
normal  
closed 3.1.9  
fixed  
none    
none 3.1.10  
0003837: DBPool does not wait for connections according to logic specified by <connection-wait-time>
I created a
simple WAR that you can drop into any resin instance to see what I'm seeing.
I'll also include a link to my production server where you can see it
running.

 I wrote a JSP page that launches a several threads, grabs connections from
the DataSource, sleeps, then returns the connection to the pool.

I have a datasource configured in resin.conf as follows:

   <database>
     <jndi-name>conTest</jndi-name>
     <driver type="com.mysql.jdbc.Driver">
       <url>jdbc:mysql://xxx</url> [^]
       <user>x</user>
       <password>xxx</password>
     </driver>
     <prepared-statement-cache-size>0</prepared-statement-cache-size>
     <max-connections>10</max-connections>
     <connection-wait-time>10s</connection-wait-time>
     <max-overflow-connections>0</max-overflow-connections>
     <max-idle-time>15s</max-idle-time>
   </database>

A url such as the following hit's this WAR on my production box

https://76.12.177.66:9080/con-war-1.0/conBlock.jsp?threads=20&sleep=2000 [^]

So it's creating 20 threads, with a sleep time of 2s of holding onto the
connections.

The first time you hit this page you'll notice you get exceptions that the
some of the threads were unable to retrieve connections (pool was full).
But it shouldn't be. Those threads did not wait 10s. Although they do
appear to wait roughly 2s, which means just about the time the connections
where available they are returning the pool is full.

If you reload the page you'll notice it works. That is, all 20 threads get
a connection the entire page load takes about 4s.

If you wait 15s for the pool to release idle connections, then reload the
page, the errors will reappear.

So the issue appears to be that the pool is mistakenly throwing a Pool is
full exception when the pool is growing or it's trying to grow. Once the
pool is full it seems to function as advertised.
 con-war-1.0.war [^] (11,425 bytes) 01-05-10 15:00

There are no notes attached to this issue.