List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:August 6 2009 9:08pm
Subject:Re: Automatic Reconnect
View as plain text  
On Aug 6, 2009, at 2:10 PM, Dan Cook (dancook) wrote:

> Would a connection pool help here?


Yeah, you could abuse it that way. :)

There's logic in there to let you tell it what the idle timeout is for  
connections, so it will automatically close and restart them if it  
detects that this has happened.

The stock code doesn't help with the cases where the remote DB server  
is restarted, or your network link to it bounces.  In the custom  
ConnectionPool subclass -- which you had to derive anyway -- you could  
do a ping-on-grab(), automatically closing the connection and creating  
a fresh one if the ping fails.

This feels like abuse to me, though, because ConnecitonPool exists to  
deal with cases where you would otherwise have unjustifiably many  
connections open.  You can run into the "lonely program dies over the  
weekend" case with just one connection.  With a single thread, that  
may be all there ever is.  So, you end up with this complicated pool  
mechanism just to manage a single connection.

A pool for one.  Call it ConnectionTub, if you must do it that way,  
then.
Thread
Automatic ReconnectNishant Mittal6 Aug
  • Re: Automatic ReconnectChris Morgan6 Aug
    • RE: Automatic ReconnectJim Wallace6 Aug
      • RE: Automatic Reconnectdancook)6 Aug
        • Re: Automatic ReconnectWarren Young6 Aug
          • RE: Automatic Reconnectdancook)6 Aug
            • Re: Automatic ReconnectWarren Young6 Aug
    • RE: Automatic ReconnectNishant Mittal6 Aug