--- Thomas E Jenkins <[EMAIL PROTECTED]> wrote: > On Thu, 2003-08-07 at 10:00, Stephan Diehl wrote: > > On Thursday 07 August 2003 15:10, Thomas E Jenkins wrote: > > > For what it's worth I've had the same problems. It always > > > follows my other problem, MySQL throwing (2013, 'Lost connection > > > to MySQL server during query'). > > > > Once in a while, I've seeing the same errormessage. Interestingly, > > this was always early morning and the problem went away after a > > while. It just looked like the connection run into a timeout over > > night. > > Maybe it's possible, to check for this specific errormessage in the > > DBPool.py code and reset all connections if this happens.
Although I use Firebird rather than MySQL, I created a DBPool subclass called ResilientDBPool whose getConnection method "pings" the connection it's about to return, to ensure that it's still connected to the database server. If the ping fails, ResilientDBPool tries to reestablish the connection a few times before giving up and raising an exception. As a result, the pool never gives my servlets a timed-out connection or one that could be trivially reconnected. This doesn't invalidate transaction integrity because connections that are lying around idle in the pool ought not have an active transaction anyway. Subclassing DBPool is tricky because in its constructor, it dynamically selects between threadsafe and threadunsafe versions of its getConnection method and sets the chosen method as an *instance attribute*. One needs to set 'self.getConnection' in the constructor of the subclass, rather than more conventionally overriding DBPool._threadsafe_getConnection or DBPool._unthreadsafe_getConnection. I suppose I could make this code available if anyone wants it, but the "ping" logic is database-specific. __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss