commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Heisey <apa...@elyograg.org>
Subject Re: [DBCP] Connection just obtained from datasource is invalid
Date Wed, 22 Nov 2017 16:43:49 GMT
On 11/21/2017 1:01 PM, Phil Steitz wrote:
> As I said in my first response, the most common explanation for this
> kind of exception when using DBCP is that the underlying physical
> connection is closed on the server (or network) side without DBCP
> knowing about it.  And the most common cause of that is server-side
> idle connection timeout.

I do have results from the isClosed method when the problem happens. 
That method *does* return true.

I am pretty sure that the server-side idle timeout is at MySQL's default
of 28800 seconds, or 8 hours.  The problem I am experiencing has
happened only a few minutes after starting my program, so in that case,
I would not expect a server-side timeout to happen.

> It just occurred to me that since you do not have any of the testXxx
> flags set to true, DBCP is never actually exercising the
> connections.

I have now enabled the flags for testing on create, borrow, return, and
while idle.  If this does eliminate problems, do you think my theory
might be correct, or that it's probably something else?  The
testWhileIdle flag does seem a little excessive, but I figured I would
go ahead with it.  The "SELECT 1" validation query should always be fast
as long as everything's working right ... and if it's not working right,
I am not going to mind a few seconds passing before the problem is reported.

> Is it possible that sometimes your code checks out a
> connection from the pool but does not use it?

I'm only calling the datasource getConnection in a getConnection method
of my own, and that method is only used in the methods which perform
work on a connection.  It seems unlikely that I am checking out a
connection and never using it, but to be certain I would need to do a
full review of the code in my Database class.  I should probably do that
anyway, but it's a fair amount of work, so I've been avoiding it.

Thanks,
Shawn


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


Mime
View raw message