You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mork0075 <mo...@googlemail.com> on 2009/04/03 18:53:09 UTC

DriverManager.getConnection hangs if connectionLimit is reached

Hello,

i'am trying to debug a certain problem in an application using Apache
Commons DBCP. The app is a webapp with jetty as integrated webserver.
Jetty's worker threads handle the request, obtaining a database
connection to a MySQL database using
DriverManager.getConnection("jdbc:apache:commons:dbcp:example") (no
Hibernate, Ibatis around, a self written OR Mapper instead)

This works fine until a certain scenario: if the number of concurrent
requests reaches the number of maximum connections in the connection pool.

If the connection pool can store 30 connections and you fire 29
concurrent requests to the webapp, everything is fine and you can go
with another request. If you fire 30 concurrent (this means #connections
= #concurrentRequests) it is not possible to go on in the application
getting another connection. Debugging this shows that
DriverManager.getConnection("jdbc:apache:commons:dbcp:example") hangs
for another request (after the 30 concurrent ones).

I can reproduce this with any connection pool size. Limiting the pool to
5 works fine up to 4 concurrent requests, until 5 or more concurrent
requests occur.

Have you got an idea how this can happen? (there're no exceptions and
concurrent connections below the threshold are all 'closed' (returned to
the pool), I've checked this with connectionPool.getNumActive()).

Thanks in advance
Mark

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


Re: DriverManager.getConnection hangs if connectionLimit is reached

Posted by Mork0075 <mo...@googlemail.com>.
I think so, otherwise i would run out of connections after #requests =
#connectionPoolSize. The app runs days and weeks fine, only when there's
the special scenario #concurrentRequests >= #connectionPoolSize, the
method hangs/blocks forever.

Have you any idea how to debug that? Or have you got an idea what erros
could be made during development to cause such behavior?

Wes Clark schrieb:
> Are you "closing" the connections being used so they can be returned to
> the pool? 
> 
> -----Original Message-----
> From: Mork0075 [mailto:mork0075@googlemail.com] 
> Sent: Friday, April 03, 2009 10:12 AM
> To: Commons Users List
> Subject: Re: DriverManager.getConnection hangs if connectionLimit is
> reached
> 
> Waiting is ok, but in this special case i wait for ever. Even after some
> hours it is not possible to get another connection. Only restarting the
> application does it, until the next occurance of #concurrentRequests >=
> #connections
> 
> Wes Clark schrieb:
>> How would you want it to work?  Isn't that what maximum connections 
>> means?  You get that many, and if you want more, you wait.
>>
>> -----Original Message-----
>> From: Mork0075 [mailto:mork0075@googlemail.com]
>> Sent: Friday, April 03, 2009 9:53 AM
>> To: user@commons.apache.org
>> Subject: DriverManager.getConnection hangs if connectionLimit is 
>> reached
>>
>> Hello,
>>
>> i'am trying to debug a certain problem in an application using Apache 
>> Commons DBCP. The app is a webapp with jetty as integrated webserver.
>> Jetty's worker threads handle the request, obtaining a database 
>> connection to a MySQL database using
>> DriverManager.getConnection("jdbc:apache:commons:dbcp:example") (no 
>> Hibernate, Ibatis around, a self written OR Mapper instead)
>>
>> This works fine until a certain scenario: if the number of concurrent 
>> requests reaches the number of maximum connections in the connection 
>> pool.
>>
>> If the connection pool can store 30 connections and you fire 29 
>> concurrent requests to the webapp, everything is fine and you can go 
>> with another request. If you fire 30 concurrent (this means 
>> #connections = #concurrentRequests) it is not possible to go on in the
> 
>> application getting another connection. Debugging this shows that
>> DriverManager.getConnection("jdbc:apache:commons:dbcp:example") hangs 
>> for another request (after the 30 concurrent ones).
>>
>> I can reproduce this with any connection pool size. Limiting the pool 
>> to
>> 5 works fine up to 4 concurrent requests, until 5 or more concurrent 
>> requests occur.
>>
>> Have you got an idea how this can happen? (there're no exceptions and 
>> concurrent connections below the threshold are all 'closed' (returned 
>> to the pool), I've checked this with connectionPool.getNumActive()).
>>
>> Thanks in advance
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 


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


RE: DriverManager.getConnection hangs if connectionLimit is reached

Posted by Wes Clark <wc...@guidewire.com>.
Are you "closing" the connections being used so they can be returned to
the pool? 

-----Original Message-----
From: Mork0075 [mailto:mork0075@googlemail.com] 
Sent: Friday, April 03, 2009 10:12 AM
To: Commons Users List
Subject: Re: DriverManager.getConnection hangs if connectionLimit is
reached

Waiting is ok, but in this special case i wait for ever. Even after some
hours it is not possible to get another connection. Only restarting the
application does it, until the next occurance of #concurrentRequests >=
#connections

Wes Clark schrieb:
> How would you want it to work?  Isn't that what maximum connections 
> means?  You get that many, and if you want more, you wait.
> 
> -----Original Message-----
> From: Mork0075 [mailto:mork0075@googlemail.com]
> Sent: Friday, April 03, 2009 9:53 AM
> To: user@commons.apache.org
> Subject: DriverManager.getConnection hangs if connectionLimit is 
> reached
> 
> Hello,
> 
> i'am trying to debug a certain problem in an application using Apache 
> Commons DBCP. The app is a webapp with jetty as integrated webserver.
> Jetty's worker threads handle the request, obtaining a database 
> connection to a MySQL database using
> DriverManager.getConnection("jdbc:apache:commons:dbcp:example") (no 
> Hibernate, Ibatis around, a self written OR Mapper instead)
> 
> This works fine until a certain scenario: if the number of concurrent 
> requests reaches the number of maximum connections in the connection 
> pool.
> 
> If the connection pool can store 30 connections and you fire 29 
> concurrent requests to the webapp, everything is fine and you can go 
> with another request. If you fire 30 concurrent (this means 
> #connections = #concurrentRequests) it is not possible to go on in the

> application getting another connection. Debugging this shows that
> DriverManager.getConnection("jdbc:apache:commons:dbcp:example") hangs 
> for another request (after the 30 concurrent ones).
> 
> I can reproduce this with any connection pool size. Limiting the pool 
> to
> 5 works fine up to 4 concurrent requests, until 5 or more concurrent 
> requests occur.
> 
> Have you got an idea how this can happen? (there're no exceptions and 
> concurrent connections below the threshold are all 'closed' (returned 
> to the pool), I've checked this with connectionPool.getNumActive()).
> 
> Thanks in advance
> Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 


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


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


Re: DriverManager.getConnection hangs if connectionLimit is reached

Posted by Mork0075 <mo...@googlemail.com>.
Waiting is ok, but in this special case i wait for ever. Even after some
hours it is not possible to get another connection. Only restarting the
application does it, until the next occurance of #concurrentRequests >=
#connections

Wes Clark schrieb:
> How would you want it to work?  Isn't that what maximum connections
> means?  You get that many, and if you want more, you wait. 
> 
> -----Original Message-----
> From: Mork0075 [mailto:mork0075@googlemail.com] 
> Sent: Friday, April 03, 2009 9:53 AM
> To: user@commons.apache.org
> Subject: DriverManager.getConnection hangs if connectionLimit is reached
> 
> Hello,
> 
> i'am trying to debug a certain problem in an application using Apache
> Commons DBCP. The app is a webapp with jetty as integrated webserver.
> Jetty's worker threads handle the request, obtaining a database
> connection to a MySQL database using
> DriverManager.getConnection("jdbc:apache:commons:dbcp:example") (no
> Hibernate, Ibatis around, a self written OR Mapper instead)
> 
> This works fine until a certain scenario: if the number of concurrent
> requests reaches the number of maximum connections in the connection
> pool.
> 
> If the connection pool can store 30 connections and you fire 29
> concurrent requests to the webapp, everything is fine and you can go
> with another request. If you fire 30 concurrent (this means #connections
> = #concurrentRequests) it is not possible to go on in the application
> getting another connection. Debugging this shows that
> DriverManager.getConnection("jdbc:apache:commons:dbcp:example") hangs
> for another request (after the 30 concurrent ones).
> 
> I can reproduce this with any connection pool size. Limiting the pool to
> 5 works fine up to 4 concurrent requests, until 5 or more concurrent
> requests occur.
> 
> Have you got an idea how this can happen? (there're no exceptions and
> concurrent connections below the threshold are all 'closed' (returned to
> the pool), I've checked this with connectionPool.getNumActive()).
> 
> Thanks in advance
> Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 


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


RE: DriverManager.getConnection hangs if connectionLimit is reached

Posted by Wes Clark <wc...@guidewire.com>.
How would you want it to work?  Isn't that what maximum connections
means?  You get that many, and if you want more, you wait. 

-----Original Message-----
From: Mork0075 [mailto:mork0075@googlemail.com] 
Sent: Friday, April 03, 2009 9:53 AM
To: user@commons.apache.org
Subject: DriverManager.getConnection hangs if connectionLimit is reached

Hello,

i'am trying to debug a certain problem in an application using Apache
Commons DBCP. The app is a webapp with jetty as integrated webserver.
Jetty's worker threads handle the request, obtaining a database
connection to a MySQL database using
DriverManager.getConnection("jdbc:apache:commons:dbcp:example") (no
Hibernate, Ibatis around, a self written OR Mapper instead)

This works fine until a certain scenario: if the number of concurrent
requests reaches the number of maximum connections in the connection
pool.

If the connection pool can store 30 connections and you fire 29
concurrent requests to the webapp, everything is fine and you can go
with another request. If you fire 30 concurrent (this means #connections
= #concurrentRequests) it is not possible to go on in the application
getting another connection. Debugging this shows that
DriverManager.getConnection("jdbc:apache:commons:dbcp:example") hangs
for another request (after the 30 concurrent ones).

I can reproduce this with any connection pool size. Limiting the pool to
5 works fine up to 4 concurrent requests, until 5 or more concurrent
requests occur.

Have you got an idea how this can happen? (there're no exceptions and
concurrent connections below the threshold are all 'closed' (returned to
the pool), I've checked this with connectionPool.getNumActive()).

Thanks in advance
Mark

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


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