Re: killing processes

Поиск
Список
Период
Сортировка
От David Kerr
Тема Re: killing processes
Дата
Msg-id 20090720233324.GA91950@mr-paradox.net
обсуждение исходный текст
Ответ на Re: killing processes  (Merlin Moncure <mmoncure@gmail.com>)
Ответы Re: killing processes
Список 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.marlowe@gmail.com> wrote:
- > On Mon, Jul 20, 2009 at 4:44 PM, David Kerr<dmk@mr-paradox.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

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: killing processes
Следующее
От: Steve Crawford
Дата:
Сообщение: Re: Server Backup: pg_dump vs pg_dumpall