Re: elog(FATAL) vs shared memory

From: Jim Nasby <decibel(at)decibel(dot)org>
To: Stuart Bishop <stuart(dot)bishop(at)canonical(dot)com>
Cc: Mark Shuttleworth <mark(at)ubuntu(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org, Martin Pitt <martin(dot)pitt(at)ubuntu(dot)com>
Subject: Re: elog(FATAL) vs shared memory
Date: 2007-04-11 22:23:38
Message-ID: 0A70AFA3-BEE1-4215-AA32-523E8928EFBD@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

FWIW, you might want to put some safeguards in there so that you
don't try to inadvertently kill the backend that's running that
function... unfortunately I don't think there's a built-in function
to tell you the PID of the backend you're connected to; if you're
connecting via TCP you could use inet_client_addr() and
inet_client_port(), but that won't work if you're using the socket to
connect.

On Apr 5, 2007, at 6:23 AM, Stuart Bishop wrote:

> Mark Shuttleworth wrote:
>> Tom Lane wrote:
>>> (1) something (still not sure what --- Martin and Mark, I'd
>>> really like
>>> to know) was issuing random SIGTERMs to various postgres processes
>>> including autovacuum.
>>>
>>
>> This may be a misfeature in our test harness - I'll ask Stuart
>> Bishop to
>> comment.
>
> After a test is run, the test harness kills any outstanding
> connections so
> we can drop the test database. Without this, a failing test could
> leave open
> connections dangling causing the drop database to block.
>
> CREATE OR REPLACE FUNCTION _killall_backends(text)
> RETURNS Boolean AS $$
> import os
> from signal import SIGTERM
>
> plan = plpy.prepare(
> "SELECT procpid FROM pg_stat_activity WHERE datname=$1",
> ['text']
> )
> success = True
> for row in plpy.execute(plan, args):
> try:
> plpy.info("Killing %d" % row['procpid'])
> os.kill(row['procpid'], SIGTERM)
> except OSError:
> success = False
>
> return success
> $$ LANGUAGE plpythonu;
>
> --
> Stuart Bishop <stuart(dot)bishop(at)canonical(dot)com> http://
> www.canonical.com/
> Canonical Ltd. http://www.ubuntu.com/
>

--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2007-04-11 22:24:58 Re: Vista/IPv6
Previous Message Jim Nasby 2007-04-11 22:07:19 Re: Eliminating unnecessary left joins