On Apr 25, 2009, at 4:50 PM, Jay Rajput wrote:
> I have modified the create function to set
> the ReconnectOption for connection as true.
Good tip. I've added it to the user manual.
> Does the reconnect option solves all the problems?
You tell me. :) I don't restart my MySQL servers out from under my
apps.
It can't be done by default, because even if the DB server is allowed
to restart separately from the apps using it, those apps might want to
be able to detect that this has happened, if only so they can log the
incident. Doing it in create() is the right thing, since it's a per-
app policy issue.
> Is there a way to find out the bad connection without executing a
> query
> on it. Something like ping ?
That's *almost* correct, and so, I've just added
Connection::safe_grab() to the svn version. It will appear in 3.1.0,
but the current svn version is safe enough to use, I think. svn MySQL+
+ will destabilize again at least once more before release, but right
now, it should be stable.
The problem with pinging the connection before returning it is that
the DB server could be restarted between the time ping() succeeds and
you try to issue a query. Your code still has to be able to cope with
the server going away, either by doing the ReconnectOption or by using
the new...
...exchange() method, which I've also added in svn. And, there's also
a new remove() method, as originally proposed, used internally by
exchange(), but also usable by your own code if you want to do
something similar to exchange() but different.