Re: Kill a session

From: Mark Kirkwood <markir(at)paradise(dot)net(dot)nz>
To: "Craig A(dot) James" <cjames(at)modgraph-usa(dot)com>
Cc: Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Kill a session
Date: 2006-07-14 01:30:39
Message-ID: 44B6F3BF.1000602@paradise.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Craig A. James wrote:
>
>
> I'm back to my original question: How do you kill a runaway query
> without bringing down the whole database? Is there really no answer to
> this?
>

As others have mentioned, pg_cancel_backend(pid) will stop query
execution by backend process id 'pid'.

While this is often enough, if you actually want to disconnect a backend
process then there is nothing to let you do this remotely. I recently
did a patch for Bizgres that just implements the
pg_terminate_backend(pid) function (currently #ifdef'ed out of the
codebase) as a contrib so it can be easily installed. See
http://pgfoundry.org/pipermail/bizgres-general/2006-May/000484.html

If you want to try it out, please read the README (it discusses possible
dangers associated with sending SIGTERM to backends). And I would
certainly be interested in hearing what level of success (or otherwise)
you have with it!

Best wishes

Mark

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Craig A. James 2006-07-14 02:17:14 Re: Kill a session
Previous Message Tom Lane 2006-07-13 22:32:58 Re: Problem with bitmap-index-scan plan