Re: Change pg_cancel_*() to ignore current backend

Поиск
Список
Период
Сортировка
От Eric Ridge
Тема Re: Change pg_cancel_*() to ignore current backend
Дата
Msg-id CANcm6wb_yAqaHTwoz66+dfPmj1gu6hS__mDns8fVzPo+ajSx8Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Change pg_cancel_*() to ignore current backend  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Список pgsql-hackers
On Fri, May 22, 2015 at 4:51 PM Jim Nasby <Jim.Nasby@bluetreble.com> wrote:
Interesting idea. I suspect that would be even more invasive than
modifying the functions though...

Here's the solution.  I can't see how anyone could possibly disagree with this... ;)

Change the sort order for pg_stat_activity so the current session sorts last.  That way all the other sessions get killed first when doing select pg_terminate_backend(pid) from pg_stat_activity. 

When I get bitten by this, I don't really care that my session gets killed, I care that it gets killed before all the others.  Personally, I only do this sort of thing interactively via psql, and typically ^D as soon as the query finishes (which means the second time I run psql and add a WHERE clause to the query).

Alternatively, queue up pg_cancel/terminate_backend calls and process them only on successful transaction commit, in such an order that the current session is processed last.  They'd be consistent with NOTIFY too, which might be an added bonus.

eric

ps, sorry my last message was from corporate email w/ the stupid "legal" disclaimer.  

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

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: jsonb_set: update or upsert default?
Следующее
От: CharSyam
Дата:
Сообщение: patch: change magic constants to DEFINE value for readability.