Re: Killing the backend to cancel a long waiting query - Mailing list pgsql-hackers

From Robert Treat
Subject Re: Killing the backend to cancel a long waiting query
Date
Msg-id 1064255371.25694.1903.camel@camel
Whole thread Raw
In response to Re: Killing the backend to cancel a long waiting query  ("Paulo Scardine" <paulos@cimed.ind.br>)
List pgsql-hackers
On Mon, 2003-09-22 at 13:53, Paulo Scardine wrote:
> I can implement it as C functions, I think.
> Would be nice to have something like:
> 
> Test=# select pg_list_backends();
>   pid  | conn_id  |   user   | database  | time |     host      | status
> -------+----------+----------+-----------+------+---------------+--------
>   4724 | 35445134 | marcelo  | test      | 0:34 | 192.168.2.212 | select
>  18737 | 15412337 | postgres | template1 | 0:00 | 192.168.1.65  | idle
>  18693 | 11448964 | postgres | test      | 0:00 | 127.0.0.1     | idle
> (3 rows)
> 
> Test=# select pg_stopquery_pid(4724);
>  pg_stopquery_pid
> ------------------
>                 0
> 
> Is it worth?

Yes, but you may need a way to ensure that the query canceled is the
same one that you really want to cancel. (imagine come connection
pooling and bad luck mixed together so that the long running query
actually ends but another query fires up between the time you lookup the
long running query and the time you issue the kill...). maybe
transaction id as well as pid for arguments?

Robert Treat 
-- 
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: missing pg_clog files ?
Next
From: Hannu Krosing
Date:
Subject: Re: PostgreSQL not ACID compliant?