> On 13 Dec 2025, at 12:44, Roman Khapov <[email protected]> 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.



Reply via email to