Skip site navigation (1) Skip section navigation (2)

Request about pg_terminate_backend()

From: "Saleem EDAH-TALLY" <nmset(at)netcourrier(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Request about pg_terminate_backend()
Date: 2009-07-28 17:19:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers

Version 8.4 has brought a very useful function : pg_terminate_backend()

There have been many reports since years about idle processes remaining on the 
server while clients are no longer connected. While this may be due to poor 
application code not closing connections correctly, it does happen that a 
regular call to close an open connection fails SILENTLY for whatever reason 
(poor network I/O, router buffers full, p2p on the network). This can impair 
server resources seriously without being noticed. (I have seen same situation 
with Oracle too).

pg_terminate_backend() allows to explicitly kill a process through a pl/pgsql 
function in a client application. The following does it somehow rightly :

create or replace function suicide() returns void as $$
res boolean;
p integer;
select pg_backend_pid() into p;
set log_min_error_statement = PANIC;
set log_min_messages = PANIC;
select pg_terminate_backend(p) into res;
set log_min_messages = WARNING;
set log_min_error_statement = ERROR;
$$ language plpgsql security definer;

My request is as follows : that superuser privileges be unnecessary to call 
the function, that when called by an unprivileged user, it does not raise an 
error situation and that no error is logged. After all, a user is allowed to 
close his connection.

Please consider.

Thank you.


pgsql-hackers by date

Next:From: Jaime CasanovaDate: 2009-07-28 17:19:33
Subject: Re: fix: plpgsql: return query and dropped columns problem
Previous:From: Robert HaasDate: 2009-07-28 17:12:47
Subject: Re: fix: plpgsql: return query and dropped columns problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group