cleaning up backend process after death of CGI process - Mailing list pgsql-general

From Moore, Duane
Subject cleaning up backend process after death of CGI process
Date
Msg-id EFEE6F7115D3CF11B70A00805FA66198010705D5@cosexchange.cos.gsc.gte.com
Whole thread Raw
List pgsql-general
I am having a small problem using postgres with a libpq++ based CGI program.
The program works fine almost all of the time.  However, from time to time,
the machine running postgres will have several backend processes running
that are simply burning CPU cycles.  I think that I have tracked down the
root of the problem to be a stray backend process that was not cleaned up
whenever someone hit the "Stop" or "Cancel" button on their browser while
performing a large database search.  Once this happens, the stray process
prevents other processes from accessing the data they need in a timely
fashion (or at all).

So my question is twofold:  Is there a way to detect when my CGI program is
killed by the web server (I'm using Netscape Enterprise 3.5) by catching a
signal or something?  This way I could close any postgres connections,
though I'm not sure that simply deleting the PgDatabase object would prevent
whatever is happening right now.

Secondly, is there (or shouldn't there be) a way that Postgres can detect
when it has lost the connection to the front end process (the client) and
automatically clean up so that the "cancelled" processes are not still lying
around?

Please cc any responses to me since I am not subscribed to the list yet.

Thanks,
Duane Moore
duane.moore@gsc.gte.com

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [ADMIN] Re: [SQL] Data recovery
Next
From: srcho@newcc.co.kr (songraeCHO)
Date:
Subject: How to use korean in Postgres6.4.2