On Mon, Aug 23, 2004 at 09:53:43AM +0100, Graeme Hinchliffe wrote:
> I am writing a daemon in C which monitors a table stored in postgres.
> I would ideally like the daemon to be able to withstand things such as
> the db connection going away or the db being shutdown, and simply keep
> trying to connect rather than just fall on it's face.
> Is there a way that I can catch a server shutdown/connection loss
> cleanly? I did a quick search of the mailling list but didn't see
Normally when the database exits, clients receive an error on the next
transaction usually. I create a wrapper for query executations which,
when noticing the database has gone, tries to reopen the connection. It
returns unknown if it fails. Not exactly compatable with transactions
Hope this helps,
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
In response to
pgsql-general by date
|Next:||From: Ennio-Sr||Date: 2004-08-23 13:59:40|
|Subject: Checking whether postgresql is running|
|Previous:||From: Martijn van Oosterhout||Date: 2004-08-23 13:29:08|
|Subject: Re: Greatest/Least functions?|