DBCP Returning Closed Connections

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

DBCP Returning Closed Connections

Khawaja Shams
Hello,   One of our servers goes through periods of activity followed by
long idle durations.  It appears as though after the server sits idle for a
few hours, subsequent requests to the DBCP Pool return connections that have
already been closed. This is a bit frustrating as I could not find a way to
take that connection out of the pool, and the same instance of the
connection keeps getting returned to other requests.  The connection is to a
MySQL server.  I tried setting the testOnBorrow variable to true (I am using
BasicDataSource) before the first time I borrow the connection, but it does
not seem to have any impact.  Does anybody have a work around or a hunch as
to what I may be doing wrong? Thanks.


Regards,
Khawaja Shams
Reply | Threaded
Open this post in threaded view
|

RE: DBCP Returning Closed Connections

wesclark
We've had the same problem on SQL Server. Set the "testWhileIdle" to
test a few connections every so often.  It will keep the connections
alive.

-----Original Message-----
From: Khawaja Shams [mailto:[hidden email]]
Sent: Wednesday, September 17, 2008 12:40 PM
To: [hidden email]
Subject: DBCP Returning Closed Connections

Hello,   One of our servers goes through periods of activity followed by
long idle durations.  It appears as though after the server sits idle
for a few hours, subsequent requests to the DBCP Pool return connections
that have already been closed. This is a bit frustrating as I could not
find a way to take that connection out of the pool, and the same
instance of the connection keeps getting returned to other requests.
The connection is to a MySQL server.  I tried setting the testOnBorrow
variable to true (I am using
BasicDataSource) before the first time I borrow the connection, but it
does not seem to have any impact.  Does anybody have a work around or a
hunch as to what I may be doing wrong? Thanks.


Regards,
Khawaja Shams

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: DBCP Returning Closed Connections

Khawaja Shams
  Thanks Wes for the suggestion.  Should I file a bug for testOnBorrow not
testing the connections properly?



On Wed, Sep 17, 2008 at 1:11 PM, Wes Clark <[hidden email]> wrote:

> We've had the same problem on SQL Server. Set the "testWhileIdle" to
> test a few connections every so often.  It will keep the connections
> alive.
>
> -----Original Message-----
> From: Khawaja Shams [mailto:[hidden email]]
> Sent: Wednesday, September 17, 2008 12:40 PM
> To: [hidden email]
> Subject: DBCP Returning Closed Connections
>
> Hello,   One of our servers goes through periods of activity followed by
> long idle durations.  It appears as though after the server sits idle
> for a few hours, subsequent requests to the DBCP Pool return connections
> that have already been closed. This is a bit frustrating as I could not
> find a way to take that connection out of the pool, and the same
> instance of the connection keeps getting returned to other requests.
> The connection is to a MySQL server.  I tried setting the testOnBorrow
> variable to true (I am using
> BasicDataSource) before the first time I borrow the connection, but it
> does not seem to have any impact.  Does anybody have a work around or a
> hunch as to what I may be doing wrong? Thanks.
>
>
> Regards,
> Khawaja Shams
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

RE: DBCP Returning Closed Connections

wesclark
We don't use testOnBorrow because we return connections to the pool
after a select if not in an update transaction, so it would be too
expensive to run a query every time we borrow.

-----Original Message-----
From: Khawaja Shams [mailto:[hidden email]]
Sent: Wednesday, September 17, 2008 2:35 PM
To: Commons Users List
Subject: Re: DBCP Returning Closed Connections

  Thanks Wes for the suggestion.  Should I file a bug for testOnBorrow
not testing the connections properly?



On Wed, Sep 17, 2008 at 1:11 PM, Wes Clark <[hidden email]> wrote:

> We've had the same problem on SQL Server. Set the "testWhileIdle" to
> test a few connections every so often.  It will keep the connections
> alive.
>
> -----Original Message-----
> From: Khawaja Shams [mailto:[hidden email]]
> Sent: Wednesday, September 17, 2008 12:40 PM
> To: [hidden email]
> Subject: DBCP Returning Closed Connections
>
> Hello,   One of our servers goes through periods of activity followed
by
> long idle durations.  It appears as though after the server sits idle
> for a few hours, subsequent requests to the DBCP Pool return
> connections that have already been closed. This is a bit frustrating
> as I could not find a way to take that connection out of the pool, and

> the same instance of the connection keeps getting returned to other
requests.
> The connection is to a MySQL server.  I tried setting the testOnBorrow

> variable to true (I am using
> BasicDataSource) before the first time I borrow the connection, but it

> does not seem to have any impact.  Does anybody have a work around or
> a hunch as to what I may be doing wrong? Thanks.
>
>
> Regards,
> Khawaja Shams
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: DBCP Returning Closed Connections

Phil Steitz-2
In reply to this post by Khawaja Shams
Khawaja Shams wrote:
>   Thanks Wes for the suggestion.  Should I file a bug for testOnBorrow not
> testing the connections properly?
>  
Yes, if you have testOnBorrow set to true and you are getting
connections back that are closed, that is a bug.

>
>
> On Wed, Sep 17, 2008 at 1:11 PM, Wes Clark <[hidden email]> wrote:
>
>  
>> We've had the same problem on SQL Server. Set the "testWhileIdle" to
>> test a few connections every so often.  It will keep the connections
>> alive.
>>
>> -----Original Message-----
>> From: Khawaja Shams [mailto:[hidden email]]
>> Sent: Wednesday, September 17, 2008 12:40 PM
>> To: [hidden email]
>> Subject: DBCP Returning Closed Connections
>>
>> Hello,   One of our servers goes through periods of activity followed by
>> long idle durations.  It appears as though after the server sits idle
>> for a few hours, subsequent requests to the DBCP Pool return connections
>> that have already been closed. This is a bit frustrating as I could not
>> find a way to take that connection out of the pool, and the same
>> instance of the connection keeps getting returned to other requests.
>> The connection is to a MySQL server.  I tried setting the testOnBorrow
>> variable to true (I am using
>> BasicDataSource) before the first time I borrow the connection, but it
>> does not seem to have any impact.  Does anybody have a work around or a
>> hunch as to what I may be doing wrong? Thanks.
>>
>>
>> Regards,
>> Khawaja Shams
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: DBCP Returning Closed Connections

Khawaja Shams
In reply to this post by wesclark
Wes,   While I admit that testWhileIdle is a much better solution, I had
figured that it would not be too expensive to set testOnBorrow for a simple
reason: my impression from reviewing the code is that  if you do not
explicitly set the query string, DBCP just does a connection.isClosed()
check, which should fail if the test was invoked. After ensuring the
connection is open, DBCP will run your query (if it is not null).  This is
what I gathered from reading the code, but I may be wrong :).


Regards,
Khawaja

On Wed, Sep 17, 2008 at 2:58 PM, Wes Clark <[hidden email]> wrote:

> We don't use testOnBorrow because we return connections to the pool
> after a select if not in an update transaction, so it would be too
> expensive to run a query every time we borrow.
>
> -----Original Message-----
> From: Khawaja Shams [mailto:[hidden email]]
> Sent: Wednesday, September 17, 2008 2:35 PM
> To: Commons Users List
> Subject: Re: DBCP Returning Closed Connections
>
>  Thanks Wes for the suggestion.  Should I file a bug for testOnBorrow
> not testing the connections properly?
>
>
>
> On Wed, Sep 17, 2008 at 1:11 PM, Wes Clark <[hidden email]> wrote:
>
> > We've had the same problem on SQL Server. Set the "testWhileIdle" to
> > test a few connections every so often.  It will keep the connections
> > alive.
> >
> > -----Original Message-----
> > From: Khawaja Shams [mailto:[hidden email]]
> > Sent: Wednesday, September 17, 2008 12:40 PM
> > To: [hidden email]
> > Subject: DBCP Returning Closed Connections
> >
> > Hello,   One of our servers goes through periods of activity followed
> by
> > long idle durations.  It appears as though after the server sits idle
> > for a few hours, subsequent requests to the DBCP Pool return
> > connections that have already been closed. This is a bit frustrating
> > as I could not find a way to take that connection out of the pool, and
>
> > the same instance of the connection keeps getting returned to other
> requests.
> > The connection is to a MySQL server.  I tried setting the testOnBorrow
>
> > variable to true (I am using
> > BasicDataSource) before the first time I borrow the connection, but it
>
> > does not seem to have any impact.  Does anybody have a work around or
> > a hunch as to what I may be doing wrong? Thanks.
> >
> >
> > Regards,
> > Khawaja Shams
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: DBCP Returning Closed Connections

Khawaja Shams
Hello,  Okay, I take this back.  It turns out that in the createDataSource
method, BasicDataSource class sets all of the test flags to false if it the
validation query is null.  I will set our code to do testWhileIdle and set
the validationQuery to be valid.  Thanks again everyone.


Regards,
Khawaja Shams

On Thu, Sep 18, 2008 at 2:21 AM, Khawaja Shams <[hidden email]> wrote:

> Wes,   While I admit that testWhileIdle is a much better solution, I had
> figured that it would not be too expensive to set testOnBorrow for a simple
> reason: my impression from reviewing the code is that  if you do not
> explicitly set the query string, DBCP just does a connection.isClosed()
> check, which should fail if the test was invoked. After ensuring the
> connection is open, DBCP will run your query (if it is not null).  This is
> what I gathered from reading the code, but I may be wrong :).
>
>
> Regards,
> Khawaja
>
>
> On Wed, Sep 17, 2008 at 2:58 PM, Wes Clark <[hidden email]> wrote:
>
>> We don't use testOnBorrow because we return connections to the pool
>> after a select if not in an update transaction, so it would be too
>> expensive to run a query every time we borrow.
>>
>> -----Original Message-----
>> From: Khawaja Shams [mailto:[hidden email]]
>> Sent: Wednesday, September 17, 2008 2:35 PM
>> To: Commons Users List
>> Subject: Re: DBCP Returning Closed Connections
>>
>>  Thanks Wes for the suggestion.  Should I file a bug for testOnBorrow
>> not testing the connections properly?
>>
>>
>>
>> On Wed, Sep 17, 2008 at 1:11 PM, Wes Clark <[hidden email]> wrote:
>>
>> > We've had the same problem on SQL Server. Set the "testWhileIdle" to
>> > test a few connections every so often.  It will keep the connections
>> > alive.
>> >
>> > -----Original Message-----
>> > From: Khawaja Shams [mailto:[hidden email]]
>> > Sent: Wednesday, September 17, 2008 12:40 PM
>> > To: [hidden email]
>> > Subject: DBCP Returning Closed Connections
>> >
>> > Hello,   One of our servers goes through periods of activity followed
>> by
>> > long idle durations.  It appears as though after the server sits idle
>> > for a few hours, subsequent requests to the DBCP Pool return
>> > connections that have already been closed. This is a bit frustrating
>> > as I could not find a way to take that connection out of the pool, and
>>
>> > the same instance of the connection keeps getting returned to other
>> requests.
>> > The connection is to a MySQL server.  I tried setting the testOnBorrow
>>
>> > variable to true (I am using
>> > BasicDataSource) before the first time I borrow the connection, but it
>>
>> > does not seem to have any impact.  Does anybody have a work around or
>> > a hunch as to what I may be doing wrong? Thanks.
>> >
>> >
>> > Regards,
>> > Khawaja Shams
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>