Re: killing processes

From: David Kerr <dmk(at)mr-paradox(dot)net>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: killing processes
Date: 2009-07-20 23:33:24
Message-ID: 20090720233324.GA91950@mr-paradox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jul 20, 2009 at 07:18:07PM -0400, Merlin Moncure wrote:
- On Mon, Jul 20, 2009 at 6:48 PM, Scott Marlowe<scott(dot)marlowe(at)gmail(dot)com> wrote:
- > On Mon, Jul 20, 2009 at 4:44 PM, David Kerr<dmk(at)mr-paradox(dot)net> wrote:
- > What's most likely happening is that it's stuck in a tight loop that
- > doesn't check for interrupts, so it just keeps on going.
- >
- > You can kill -9 a process.  It'll cause the postmaster to kill all
- > backends and flush the buffers if I remember correctly.
-
- That's right -- and if there is any case where built in functions,
- sql, or pgsql functions get stuck in such a way that a kill -9 is
- required, it should be reported so that it can be fixed. Trust me,
- you should avoid kill -9 if at all possible. Backend C functions you
- write should check interrupts at appropriate places so you can respond
- to cancels appropriately with CHECK_FOR_INTERRUPTS();
-
- A good example if how this is done, take a look at ITAGAKI's proposed
- enhancement of dblink and the attached patch here:
-
- http://www.nabble.com/query-cancel-issues-in-contrib-dblink-td24214133.html

Thanks guys.

I wonder if this is a case for a bug, of course, it's probably not reproduceable.
But, i don't see any coded loop or way for me to insert a signal check. (I'm not much of a
programmer) the function was just:

CREATE OR REPLACE FUNCTION array_median(anyarray)
RETURNS anyelement AS
$$
SELECT CASE
WHEN array_upper($1,1) = 0 THEN null
WHEN mod(array_upper($1,1),2) = 1 THEN
asorted[ceiling(array_upper(asorted,1)/2.0)]
ELSE
((asorted[ceiling(array_upper(asorted,1)/2.0)] + asorted[ceiling(array_upper(asorted,1)/2.0)+1])/2.0) END
FROM (SELECT ARRAY(SELECT ($1)[n] FROM
generate_series(1, array_upper($1, 1)) AS n
WHERE ($1)[n] IS NOT NULL
ORDER BY ($1)[n]
) As asorted) As foo ;
$$
LANGUAGE 'sql' IMMUTABLE;

(got it from here - thanks to the author =) )
http://www.postgresonline.com/journal/index.php?/archives/67-Build-Median-Aggregate-Function-in-SQL.html

Thanks

Dave

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Crawford 2009-07-21 00:03:30 Re: Server Backup: pg_dump vs pg_dumpall
Previous Message Tom Lane 2009-07-20 23:26:20 Re: killing processes