Additional message in pg_terminate_backend

Поиск
Список
Период
Сортировка
От Roman Khapov
Тема Additional message in pg_terminate_backend
Дата
Msg-id 064E214D-D86F-4917-A0B6-67EAD6BCB24A@yandex-team.ru
обсуждение исходный текст
Список pgsql-hackers
Hi hackers!

Recently I started working on patch for adding additional message from admin
in pg_terminate_backend for one of our greenplum fork. The main idea is that there must be
done little investigation every time you see 'FATAL:  terminating connection due to administrator command’ to
understandthe reason, especially in cases where connection was terminated by another 
user. So it was decided to create some new functions, that allows to terminate connection with
additional message.

I did POC patches with the next main ideas:
 - lets add termReasonStr field in every PGPROC, that field can be used in ProcessInterrupts()
 - implementation of pg_terminate_backend/pg_cancel_backend should be accessible from extensions, so lets move it in
pg_terminate_backend_impl/pg_cancel_backend_impland add definitions for it somewhere 
 - write simple extensions, which defines functions like pg_terminate_backend_msg, that sets termReasonStr and calls
pg_terminate_backend_impl

After patch and added extension, it is possible to do smth like:
postgres=# select pg_terminate_backend_msg(pg_backend_pid(), 0, ’the message');
FATAL:  terminating connection due to administrator command: the message

The general question I want to ask: can this patches be useful for vanilla PostgreSQL?

If so, there are some questions about patch improvements:
 - maybe the message can be delivered to backend by some other way than the field in struct PGPROC?
termReasonStr field consumes some shared memory and are used in rare cases
 - names of all new funcs/fields/etc should be changed to some better names
 - new file signalfuncs.h seems like too complicated solutions to define *_impl functions, it can be done in
some other files?

-----
Best regards,
Roman Khapov


Вложения

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