| From: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
|---|---|
| To: | Roman Khapov <rkhapov(at)yandex-team(dot)ru> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Additional message in pg_terminate_backend |
| Date: | 2025-12-17 11:34:09 |
| Message-ID: | 288F67CA-E019-40B6-892F-54B5D000C18D@yandex-team.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On 13 Dec 2025, at 12:44, Roman Khapov <rkhapov(at)yandex-team(dot)ru> wrote:
>
> 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 understand the 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.
Overall idea seems good to me.
Keep in mind that Postgres literals are translated into many languages. So text ought to be clear enough for translators to build a sentence that precedes termination reason.
>
> 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_impl and 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
First thing that we need to do is to agree on API of the new feature. We do not need core-extension separation for this.
My vote would be for having pg_cancel_backend(reason text)\pg_terminate_backend(reason text) along with parameterless versions.
32 bytes per PGPROC seems reasonable for a "reason". The patch doesn't seem to take care of cleaning "termReasonStr". Is it done elsewhere?
We have a race condition if many backends cancel same backend. Won't they mess each other's reason?
Thanks!
Best regards, Andrey Borodin.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mihail Nikalayeu | 2025-12-17 11:35:00 | Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY |
| Previous Message | Andrei Lepikhov | 2025-12-17 11:10:31 | Re: Parallel Apply |