On 11/22/17 9:43 AM, Shawn Heisey wrote: > 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.
That points to a Pool or DBCP bug, assuming you are sure that no other thread has a reference to the PoolableConnection or some other code path did not call close on it before you tested isClosed. If you are sure this is not happening, you should open a DBCP JIRA (which may end up reassigned to pool). Ideal would be to have a test case that makes it happen. > > 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. Makes sense, so can rule that out. > >> 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? Your theory that it is a pool bug? If adding those tests makes the problem go away, that might just be due to timing. > 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. Code review is always great ;) but given that the problem happens close to startup, it is not likely that the connections are being closed server-side. The fact that isClosed is returning true when the problem happens also rules that out - it means that DBCP knows that the connection is closed. That doesn't happen when server-side timeouts happen. > > Thanks, > Shawn > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@commons.apache.org > For additional commands, e-mail: user-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org