Re: Killing the backend to cancel a long waiting query

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: Paulo Scardine <paulos(at)cimed(dot)ind(dot)br>
Cc: Dave Page <dpage(at)vale-housing(dot)co(dot)uk>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Killing the backend to cancel a long waiting query
Date: 2003-09-22 18:29:31
Message-ID: 1064255371.25694.1903.camel@camel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces pgsql-odbc

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2003-09-22 19:00:43 Re: PostgreSQL not ACID compliant?
Previous Message Alvaro Herrera 2003-09-22 18:21:43 Re: missing pg_clog files ?

Browse pgsql-interfaces by date

  From Date Subject
Next Message Paulo Scardine 2003-09-22 19:02:57 Re: Killing the backend to cancel a long waiting query
Previous Message Paulo Scardine 2003-09-22 17:53:45 Re: Killing the backend to cancel a long waiting query

Browse pgsql-odbc by date

  From Date Subject
Next Message Paulo Scardine 2003-09-22 19:02:57 Re: Killing the backend to cancel a long waiting query
Previous Message Paulo Scardine 2003-09-22 17:53:45 Re: Killing the backend to cancel a long waiting query