K
Keg
Hey all,
Trying to determine a reliable, rock-solid, low-cost method of testing
a database handle.
If the database is down or the connection fails or anything that will
cause operations on a database handle to fail, will my database handle
be undefined then? I wonder because the following code gives me
inconsistent results when the system load gets high:
if (!defined($dbh1)) {
.....
Is this a rock solid way of testing your database connection? Does
anyone use $dbh1->ping??? The documentation says that unless you know
for sure you need to use the ping() method, you likely don't.
Basically I have a daemon written in perl that runs 24/7 and analyzes
various processes and logs information to a mysql database. Inside my
main loop I check the database handle each iteration and if it is
down, I spin until a connection can be re-established. However, my
problem lies in the testing of the connection and how to properly do
this.
I can't afford to disconnect and reconnect, this is a very
high-throughput process. I also want to avoid using a SQL query just
to test if the database handle is still valid or not.
My environment is RH 9 running a vanilla 2.4.20-28.9smp kernel, a
vanilla build of mysql-max-4.0.18, perl DBI 1.42, DBD::mysql 2.9003,
and vanilla perl 5.8.
Thx,
Keg
Trying to determine a reliable, rock-solid, low-cost method of testing
a database handle.
If the database is down or the connection fails or anything that will
cause operations on a database handle to fail, will my database handle
be undefined then? I wonder because the following code gives me
inconsistent results when the system load gets high:
if (!defined($dbh1)) {
.....
Is this a rock solid way of testing your database connection? Does
anyone use $dbh1->ping??? The documentation says that unless you know
for sure you need to use the ping() method, you likely don't.
Basically I have a daemon written in perl that runs 24/7 and analyzes
various processes and logs information to a mysql database. Inside my
main loop I check the database handle each iteration and if it is
down, I spin until a connection can be re-established. However, my
problem lies in the testing of the connection and how to properly do
this.
I can't afford to disconnect and reconnect, this is a very
high-throughput process. I also want to avoid using a SQL query just
to test if the database handle is still valid or not.
My environment is RH 9 running a vanilla 2.4.20-28.9smp kernel, a
vanilla build of mysql-max-4.0.18, perl DBI 1.42, DBD::mysql 2.9003,
and vanilla perl 5.8.
Thx,
Keg