Re: need a method to ping a running database

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: Travis Hume <travis(dot)hume(at)tenzing(dot)com>, pgsql-general(at)postgresql(dot)org, Breck Thomas <Breck(dot)Thomas(at)tenzing(dot)com>
Subject: Re: need a method to ping a running database
Date: 2003-06-12 19:19:49
Message-ID: 200306121219.49886.scrawford@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Sure. I did not say it was "incorrect"...
> But it is *different* from most if not all other errors, because it
> requires a different item...

It just depends on the use of the script (about which I didn't know the
details). If the only purpose is to determine if I can run queries then the
simple test will do. If the purpose is to determine whether or not to
start/restart the db server then my "script" is not complete.

> > Still, I
> >think it's safer to look for the existence of expected results that the
> >absence of specific error messages.
>
> I don't know what is "safer" about it... :-)
> It seems to be more like a question of taste...

Not taste - just the voice of experience from one who has been burned. Suppose
your db is on a remote machine and someone screws up DNS so the host doesn't
resolve or the db admin has made an error in updating pg_hba.conf or a
network cable is unplugged or a routing table is damaged. You can even have
something as silly as psql being deleted or not in the path. None of these
cases will yield the string "ERROR" so a script that looks for the absence of
"ERROR" will say everything is OK.

I've given up trying to dream up/test for every possible error - there are too
many and once I think I've thought of them all I "discover" another. :)

Checking for a known expected result will definitely let you know if the db is
or is not available (note, not available != down - just not available to the
testing program - again it depends on the purpose of your script).

Cheers,
Steve

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2003-06-12 19:26:53 Re: LAST_INSERT_ID equivalent
Previous Message Erik Price 2003-06-12 19:17:22 Re: LAST_INSERT_ID equivalent