You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Andre Schild <a....@aarboard.ch> on 2005/07/28 19:14:46 UTC

Race condition in DBCP ?

Hello,

we are using Tomcat 5.5.9 on differnt servers.
On one SMP linux server we have seen 2-3 times 
a "Pool exhausted" error.

After much searching and analyzing we think that there
exists a race condition in DBCP when you set a very low
maxWait time in the context.xml.

We had a maxWait of 10ms set (yes, it's very low) in the
past.

When the server was under high load, it consumed all
allowed connections toward the database and did finaly 
return a "pool exhausted" error.

We have also instrumented tomcat with JMX and have monitored
the DBCP pools (5 sec interval)

And we realy have seen that under very high load a lot of
DB connections are allocated by the pool.

I think the following happens:

1. class requests a connection from the pool
2. DBCP has no available connection in the pool
3. DBCP maxActive is not reached
4. DBCP starts a maxWait timer
5. DBCP trys to create a DB connection
6. The DB connection is not created after maxWait time
7. goto 2.
8. After in Step 3 maxActive is reached then
   whole create-loop is stoped and the "pool exhausted" is thrown

Perhaps the above scenario only occurs under SMP systems...

  <Resource name="$project.datasourcename" 
            auth="Container"
            type="javax.sql.DataSource" 
            username="$project.databaseloginname" 
            password="$project.databaseloginpassword"
            driverClassName="$project.databasedriver" 
            url="$project.databaseurl"
            maxActive="1000" 
            maxIdle="30"
            maxWait="500"
            removeAbandoned="true"
            removeAbandonedTimeout="7300"
            logAbandoned="true"
            validationQuery="select * from dummy"
	    />

Any Ideas if this could be the problem ?

Thanks

André



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org