On Tue, Apr 28, 2009 at 6:19 PM, Bill Moseley <[email protected]> wrote:
> Ima::DBI and DBIx::Class::Storage::DBI both call ping() to check if
> the database is alive before retuning a cached $dbh.
>
> I'm curious if this is a smart approach for a very database-heavy
> site, or if this might be a hold-over from the "morning after" problem
> where site that were quiet all night would fail in the morning as
> their connections had timed out.

Calling ping regularly is a strategy for making sure that you
reconnect to your failover when your main database goes down.

That said, I have personally seen a busy Oracle site fall over due to
the overhead of pings, and been a hero for working out a strategy that
got rid of 90% of the pinging activity.

> Is there an advantage of calling checking $dbh->FETCH( 'Active' ) &&
> $dbh->ping vs. just flagging that the dbh is dead on error and then
> reconnecting next time a $dbh is needed?

If you can automatically catch any error in dealing with the database,
and know to ping the next time you issue a dbh, that would be better.
But when I faced that problem, that approach was technically harder
because it would mean messing around with DBI internals that are
written in C.  It was much, much easier for me to just override the
ping method in Perl.

> Am I missing something obvious?

Not really.

Cheers,
Ben

Reply via email to