Re: Change pg_cancel_*() to ignore current backend

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Change pg_cancel_*() to ignore current backend
Дата
Msg-id 20150521004651.GW27868@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: Change pg_cancel_*() to ignore current backend  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Change pg_cancel_*() to ignore current backend  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On 2015-05-20 20:38:51 -0400, Tom Lane wrote:
> Jim Nasby <Jim.Nasby@BlueTreble.com> writes:
> > On 5/20/15 6:56 PM, Andres Freund wrote:
> >> On 2015-05-20 18:48:59 -0500, Jim Nasby wrote:
> >>> and generally if you want to terminate the connection there's easier
> >>> ways to do that then "SELECT pg_terminate_backend(pg_backend_pid())".
> 
> >> Which would be what exactly? Say, you're inside a security definer
> >> function.
> 
> > Error isn't good enough so you want to kill the backend?

Yep.

> > I hadn't considered that; what's the common use case for it?

I've seen it basically in two cases:
1) The "role" of the server has changed in some way, and some function  wants to force a reconnect. Say a former master
that'snow a logical  replication (in that case IIRC londiste) standby, and a trigger was  installed to rediredt
existingwriters.
 
2) A function detects that something has has gone rather wrong with a  session state and wants to force a reconnect.
I'veseen this in a  "handwritten" RLS implementation.
 

> > ISTM it'd be better 
> > to allow elog to log and then terminate the backend, but of course that 
> > doesn't help with backwards compatibility. :/
> 
> That's spelled elog(FATAL), no?

Which is, to my knowledge, inaccessible from at least plpgsql.


I've a hard time believing it's actually a good idea to change this. It
pretty much seems to only be useful if you're doing unqualified SELECT
pg_cancel_backend(pid) FROM pg_stat_activity; type queries. I don't see
that as something we need to address.



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Change pg_cancel_*() to ignore current backend
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.